What’s new for PHP runtime in the App Engine 1.8.4 release

Today we announced the 1.8.4 release of App Engine and although we’ve been busy working behind the scenes on a bunch of under the covers improvements, we’ve still managed to roll out a few nice new features and fixes for the PHP runtime. Once again, it’s worthwhile highlighting a few of these items.

The PHP interpreter was upgraded from PHP 5.4.8 to PHP 5.4.17

This picks up a lot of bug fixes from the PHP core team. For a detailed list please check the PHP5 Change Log.

The is_writable() method now supports Google Cloud Storage files and buckets.

This new feature brings us close to having Google Cloud Storage working similar to what is expected of a local file system for PHP applications. Supporting is_writable is an interesting use case – to be absolutely sure that the application has permission to write to a bucket, we have to start the process of writing an actual file to the bucket, and then check the result. As this is a comparatively time-consuming process, we cache the result in memcache the first time you call is_writable on a bucket. For example:

$my_bucket = 'gs://my_bucket/';
// Will make a request to GCS and cache the result.
$check1 = is_writable($my_bucket);
// Will retrieve the value of the previous call from the cache.  
$check2 = is_writable($my_bucket); 

Naturally this means that if you change the ACL on your Google Cloud Storage bucket, you app could read the incorrect value of is_writable from the cache. ACLs on Google Cloud Storage buckets are usually changed infrequently, so the likelihood of your app using a stale cached result is low. However, you can always flush memcache from your app’s admin console to clear the cached result.

By default the value is cached for 10 minutes, however you can change this by setting the 'writable_cache_expiry_seconds' value in the stream context configuration for Google Cloud Storage.

// Set a long writable cache timeout, as we never change the ACL on the bucket.
stream_context_set_default(['gs' => ['writable_cache_expiry_seconds' => '86400']]);

You no longer need to specify the PHP runtime when deploying applications

You longer need to specify -R when using appcfg.py to deploy php apps.

# Before
$ appcfg.py -R -A myapp update path/to/my/app/

# Now
$ appcfg.py -A myapp update path/to/my/app/