Let’s find out about Google’s recent embrace of PHP in Google App Engine, what it means for the PHP community, and how it can be improved even further if they add support for the high performing PHP framework Phalcon.
What’s Google App Engine?
Google App Engine (GAE) is Google’s cloud computing Platform as a Service offering on which users deploy web applications that live in Google’s data centers. This means any application we deploy in the environment automatically inherits the stability, interoperability, and scalability of applications such as Gmail, Google+, and more.
While a full discussion of GAE is outside the scope of this article, suffice it to say that GAE is neither a private server nor a virtual private server – it’s a platform. As such, it has some limitations. You cannot simply install extensions in it, nor can you write to disk freely. You cannot alter resource limits on your own and you cannot install custom system tools. It isn’t your average Linux box; it’s a fully managed colossal environment for enterprise-level applications.
GAE has been steadily rising in popularity over the past few years, especially for deployment of Python 2 and JVM language (Java, Scala, Clojure) applications, but only recently at Google I/O was it announced that PHP support was added due to community interest.
GAE deployment is free up to a certain point. If your app exceeds the free usage quotas, you can request a paid upgrade. It’s a pay-as-you-use model which works best for large scale high-performance applications. As such, optimizing your application and reducing the number of requests is absolutely essential. Not only does it help performance, but it literally saves you money.
Transitioning to Google App Engine
GAE’s filesystem is read-only. The only way to write something to disk (such as file uploads, cache, custom logs, etc.) is to either use an external service like a read-write CDN or use a virtual filesystem like as gae-filestore (more information is available in the Google I/O video linked above and here) or Google Cloud Storage. Furthermore, there is no such thing as a local install of MySQL/MariaDB or PostgreSQL. Instead, you have the option of using Google Cloud SQL (which is similar to MySQL but with limitations and differences we won’t be covering here).
Needless to say, the PHP developer transitioning to a GAE environment has his work cut out for him. Thankfully the Google PHP team runs a blog (which is actually a WordPress installation on GAE) with helpful hints and tutorials, and the documentation for the still experimental PHP implementation is well done. For those interested in a simple overview, there’s also the quite clear Getting Started Guide.
I encourage you to check out all the linked resources to get as acquainted as much as possible with this new environment. GAE’s endorsement of PHP is a huge shift in the PHP community, and definitely has the potential to impact PHP development in the long run.
Essential PHP Extensions and Phalcon
People have already noted the huge downside of not being able to install extensions and have requested the addition of two essential ones: mbstring and iconv (which have since been installed), making GAE’s PHP runtime that much more usable. Seeing as how PHP support is still experimental and not ready for production, the GAE team is accepting and actively looking over suggestions for new installations and upgrades.
This is where Phalcon comes into play. Phalcon is a highly advanced PHP framework written in C and installed as a PHP extension. It offers all of the framework features you’re used to and much more, but with far greater performance (more speed, fewer resources) and robustness. Written in C, it executes natively and is loaded into memory when your server starts up, essentially enhancing PHP itself with some much needed missing features.
Phalcon is more PHP6 than PHP6 in itself in some ways, and enables you to write fast and secure applications in a fraction of the time it took to build them before. If you haven’t tried Phalcon out yet, I encourage you to do so – their documentation is very complete and thorough with examples for every API call.
The problem is the aforementioned inability to install custom extensions into GAE’s PHP, which means Phalcon is permanently unavailable to such environments. Due to Phalcon’s excellent performancef, it would be a shame if it weren’t implemented since it would undoubtedly reduce both Google’s server load and the cost app owners would be faced with. This is why I’ve opened a new feature request in GAE’s issue tracker which you can vote for. So far, it’s among the top 30 requested features.
Don’t take my word for it though – try out Phalcon and see how you like it. Chances are you’ll be voting for the issue moments later. Please vote exclusively by starring, however – not by commenting. Comments are there purely for the purpose of helping out with information and potential issues during installation. When a comment is made on Google Code, an email is sent to all people who starred the issue, which might result in some people un-starring if they feel like they’re being spammed ultimately hurting the effort.
GAE is a brand new opportunity for PHP. It has the potential to revolutionize the world of PHP development and the hosting options available to developers. To be part of this new age from the get-go, stay tuned for PHP-GAE tutorials and Phalcon guides on SitePoint and follow the situations as they develop via the links in this article, in particular gaeforphp-blog.appspot.com. And don’t forget to check out Phalcon and vote for the issue to further the cause, and feel free to shoot me any questions via Google+ or in the comments below.
Bruno is a blockchain developer and technical educator at the Web3 Foundation, the foundation that's building the next generation of the free people's internet. He runs two newsletters you should subscribe to if you're interested in Web3.0: Dot Leap covers ecosystem and tech development of Web3, and NFT Review covers the evolution of the non-fungible token (digital collectibles) ecosystem inside this emerging new web. His current passion project is RMRK.app, the most advanced NFT system in the world, which allows NFTs to own other NFTs, NFTs to react to emotion, NFTs to be governed democratically, and NFTs to be multiple things at once.