Installing Yii on Google Application Engine (Java)

I’ve just started experimenting with Yii on GAE using Quercus as PHP emulator and Jiql as MySQL emulator.

The basic php/MySQL applications seems to be running with no problems.

Initial Yii requirement test shows that the setup passed basic checks. (See the link: yii-on-gae.appspot.com )

Well, I had to remove almost all i18n files to trim the framework since Google allows only 1000 files per application and I also run jiql administrator ( yii-on-gae.appspot.com/Jiqladmin.html ) to handle access to the DataStore’s BigTable which has 200 files of its own.

The problem with Yii demo application is the same as discussed in a parallel topic: server can not write to /protected/runtime directory. I do not know how Quercus Apache handle permissions (will check with there team asap).

The question: is it possible to change the location of /runtime folder?

This allowed me to get the application skeleton running in a restricted hosting environment, but may ot may not be a good place for the applications runtime files

protected/config/main.php




return array(

  ...

  'runtimePath'=>'/tmp/runtime/',

  ...

);



/Tommy

Still not writable.

Application runtime path "/tmp/runtime/" is not valid. Please make sure it is a directory writable by the Web server process.

PS I found why:

"Writing to local files is not supported in App Engine due to the distributed nature of your application. Instead, data which must be persisted should be stored in the distributed datastore.

The Sandbox

To allow App Engine to distribute requests for applications across multiple web servers, and to prevent one application from interfering with another, the application runs in a restricted “sandbox” environment. In this environment, the application can execute code, store and query data in the App Engine datastore, use the App Engine mail, URL fetch and users services, and examine the user’s web request and prepare the response.

An App Engine application cannot:

write to the filesystem. Applications must use the App Engine datastore for storing persistent data. Reading from the filesystem is allowed, and all application files uploaded with the application are available."

Looks like “this is it”. :(

A purely theoretical follow up question.

Is it at all possible to configure an Yii application to write everything - any session and cache information

  • to a database (e.g. using ‘CDbCache’ and ‘CDbHttpSession’) and do not use /runtime folder at all?

(Follow up)

The answer is yes. With the help of ‘CDbCache’ ‘CDbHttpSession’ and ‘CDbLogRoute’ it is possible to configure a Yii application to run on 100% read-only file system.

Unfortunately, with respect to running it on GAE this does not solve all problems.

The Quercus does not support full PHP PDO functionality, specifically PDO::getAttribute.

So the attempt to run Yii on GAE failed completely. :(

Writing to local files is not supported in App Engine due to the distributed nature of your application.

http://code.google.com/appengine/kb/java.html#writefile

Search for yii-app-engine project on github.com, it’s a Yii application skeleton which you can clone and upload to Google App Engine.

but before uploading you will need to create a Google Cloud Storage bucket and modify main.php file, so your assets can be saved into proper place.