不曉得 GCP Cloud Functions 到底對 PHP 支援多少東西,畢竟很多功能需要安裝 extensions,因此寫個 script 列出環境中可用的 extensions:
<?php var_dump(get_loaded_extensions());
不過很意外得發現幾乎所有 extensions 都可以用:
Array
(
[0] => Core
[1] => date
[2] => libxml
[3] => openssl
[4] => pcre
[5] => sqlite3
[6] => zlib
[7] => bcmath
[8] => bz2
[9] => calendar
[10] => ctype
[11] => curl
[12] => dba
[13] => dom
[14] => enchant
[15] => hash
[16] => fileinfo
[17] => filter
[18] => ftp
[19] => gd
[20] => gettext
[21] => gmp
[22] => SPL
[23] => iconv
[24] => intl
[25] => json
[26] => ldap
[27] => mbstring
[28] => session
[29] => pcntl
[30] => PDO
[31] => standard
[32] => pdo_pgsql
[33] => pdo_sqlite
[34] => pgsql
[35] => Phar
[36] => posix
[37] => Reflection
[38] => mysqlnd
[39] => shmop
[40] => SimpleXML
[41] => soap
[42] => sockets
[43] => pdo_mysql
[44] => exif
[45] => sysvshm
[46] => tidy
[47] => tokenizer
[48] => xml
[49] => xmlreader
[50] => xmlrpc
[51] => xmlwriter
[52] => xsl
[53] => zend-test
[54] => zip
[55] => mysqli
[56] => cgi-fcgi
[57] => Zend OPcache
)
看了 example code,也可以使用 composer,這樣彈性非常大。搞不好可以把一些服務直接搬過去了。