Quantcast
Viewing all articles
Browse latest Browse all 53

PHP on Google App Engine – Quick First Review

Image may be NSFW.
Clik here to view.
hakre-google-appengine

This is fresh out of the news (Ars; Wired; WHIR; VB), and what Google wants to offer looks like a very cool package. So if you hadn’t had the time to view the video, here is a quick summary and some first comments. Please mind that this is really fresh.

It’s basically PHP 5.4 in a “hardened edition”[1]. I think starting with PHP 5.4 on going live is a great achievement here, so this gets my PHP Applicatoratores Badge.

Also the extensions offered so far give a nice outlook, e.g. you find ZLlib and GD in there for example so you don’t hit a show stopper that fast. I name those two specifically because they became a burden with the CV-Backlog example application installment on Heroku.

However, this selection of extensions has somewhat to be improved. Default PHP extensions like iconv which actually need to be active to have other extensions properly work are not yet part of the Google PHP Runtime. To give a practical example with this iconv one, as it has got the DOM extensions activated but not the iconv extension, there is not much to deal with character encodings for our beloved DOMDocument:

$doc = new DOMDocument();
$doc->loadXML('<?xml version="1.0" encoding="Windows-1252"?><root />');
$doc->documentElement->appendChild($doc->createElement('füürüü', 'ärööö'));
echo $doc->saveXML();

This little example leaves you with a recoding related error, and no, users don’t love these (and sadly many PHP developers won’t even understand it either):

DOMDocument::saveXML(): output conversion failed due to conv error, bytes 0xFC 0xFC 0x72 0xFC
<?xml version="1.0" encoding="Windows-1252"?>
<root><f

So this needs feedback from the community I think to get the rough edges out. That one here is to make the faux-pas to not deliver PHP with iconv. But I think by the spirit of the video, these things are expected to be cleaned out after they get reported to the PHP Runtime Team @ Google (Ref: Issue 9340: ICONV PHP extension support).

For your encryption needs, this is not that harsh, even mcrypt is missing openssl is available.

However extension are not everything (and obviously something more easily to fix I assume) and these other parts are quite well solved for the PHP worlds in PHP Runtime for Google App Engine. I would say this is where it actually already shines with the now available preview.

That is: The mysql libraries work out of the box with Google CloudSQL, a Mysql 5.5 compliant managed database server on the App Engine cloud.

/* FIXME this needs a PDO example */
$connection = mysql_connect(
    $host = ":/cloudsql/project_name:instance_name", $username, $password
);

So this is quasi with zero code-changes to get an existing application run that uses any of the three Mysql client libraries (mysql_*, mysqli_*, PDO).

Similarly easy have been the problems of file storage solved. Like with other cloud-appserver-platforms, in Google App Engine you can’t change application files (and yes, your live-application deployment should not even expect to do so [yes I look at you WordPress]). However you need a place to store files to, for example for file-uploads. Google offers here something named Google Cloud Storage and it’s easily integrate with PHP via stream-wrappers. This equally should allow to port a PHP app with none or very little code-changes and especially with easy to be done changes:

$text = file_get_contents("gs://my_bucket/shakespeare.txt");

So this is really nifty, because this comes out of the box. And btw, both these features work with the development server for App Engine, so you can develop and test your apps.

Another goodie App Engine comes with is Memcached (The video has a WordPress demo that runs Batcache and this worked out of the box for example, WordPressians know what this means). And there’s Task Queue, a goodie (and fully integrated for PHP tasks now) that allows you to schedule long-taking actions inside App Engine. And there are more services in App Engine.

Summary

This Post is just a little summary of the video and some little tests I could run so far, so really a quick review. I think the package Google offers here is heading right into the right direction for todays PHP developers that are looking for a cloud platform serving PHP needs. It’s good to see more alternatives here and if you’re interested for more starting from 27:30 Jason Cartwright shows step-by-step what they did to put a Drupal based real-life site on it, which I think should show pretty well about the pros/cons such a deployment has but also how it’s done.

Compared with Heroku for PHP, I’d say Google stands out because they really put some love into getting PHP as runtime there – for the out-of-the-box experience. So I can only give the best wishes for their launch with this quick review and hope for a good working together with the PHP community. Compared with Heroku again this is necessary because different to Heroku where you can actually compile what you need, this is not possible with Google App Engine. You’re bound to the Runtime they “allow you to use”. As you know, Vendor Lock-In can have multiple Angles, so take care for directions you want to head to and try before you buy.

I will for sure give this a test-drive and let you know how it worked out. Maybe the CV-Backlog sample application with memcached temp-storage?

Resources

Jetbrains also fired-up some support for it close to the launch, a plugin for Phpstorm:


[1] Google did not specify what “hardened” actually means, I would say this translates well that the codebase has been slightly changed in a willing to improve it so you *might* find some differences in behaviour at some edges, but I have no further information about this so far.

Update: There is a list of disabled PHP functions and the /e modifer (eval) from preg_replace has been removed.


Tagged: Andrew Jessup, Appengine, Batcache, Cloud, Drupal, File-Uploads, google, Jason Cartwright, MySQL, Streamwrapper, Stuart Langley, Wordpress Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 53

Trending Articles