Google Cloud supports PHP over cloud functions
Google Cloud recently announced the public preview of PHP on Cloud Functions. The Functions Framework for PHP supports HTTP functions, to respond to HTTP events, and CloudEvent functions to process events from external and internal Google Cloud services such as Pub / Sub, Cloud Storage, and Firestore.
Cloud Functions is a serverless runtime environment for building and connecting cloud services with functions running in language-specific runtime environments, supporting Node.js, Python, Go, Java, .NET, Ruby and now PHP.
The open source functions framework for PHP is available on GitHub. It supports lightweight functions that run in different environments including local development machine, Knative-based, Cloud Run, and Cloud Run-based environments on GKE. The PHP 7.4 environment includes the runtime, the operating system, and a library that calls the function.
Brent Shaffer, Development Program Engineer at Google, and Vinod Ramachandran, Product Manager at Google, explain how to use PHP libraries:
The PHP functions framework integrates seamlessly with popular PHP development tools and processes. Include a composer.json file in your deployment, and these packages will be installed and the autoloader will be registered. Include a php.ini file, and your custom configuration will be loaded and extensions enabled.
Logging is supported using Cloud Logging, with information and error messages supported using Google’s cloud client libraries or standard error stderr. Cloud Functions isn’t the only service supporting PHP on GCP, with PHP functions supported on Cloud Run.
Adding a general purpose scripting language will expand Cloud Functions’ audience: McDougall, CTO at Squarefoot Capital and founder of the PHP User Group for South Wales, tweets:
Glad to see PHP support coming to GCP! The lack of support caused me to avoid cloud functions, now I can finally use them. So many ideas, so many options, so great.
Stephen Musoke Senkomago, e-health technologist and open source advocate, accepted:
Google finally sees the light and enters the game with PHP Cloud Functions
In a discussion thread on Reddit, user Arney points out that Google is the only cloud provider that supports PHP in functions as a service:
It looks pretty cool! I’ve always wanted to use PHP with AWS Lambda, but so far there is no official / easy support for it without using Brief for example. I’m sure there will be wrappers for Symfony / Laravel soon. Depending on the load, you may be able to run smaller websites and apps entirely under the free tier.
Regardless of the programming language used, Google Cloud offers a monthly free tier that includes two million calls to Cloud Functions, 400,000 GB-seconds and 200,000 GHz-seconds of compute time.