CodeIgniter on Google AppEngine for PHP

Google App Engine has recently announced its support for PHP, and as a CodeIgniter developer I decided to test its functionality on this great platform.

Browsing the web I found that someone had already made a port of CodeIgniter compiling it into Java applets (thru Quercus) You can check out his application here:

I’ll be testing it with the newly launched native PHP support, and using the most interesting Google Cloud products for a PHP developer: Google Cloud SQL, Cloud Storage, Memcache and AppEngine PHP-SDK Libraries.

This post is not a tutorial for Google AppEngine PHP Runtime (They already have some great documentation) nor for CodeIgniter. You are invited to consult their respective documentation if needed.

Installing AppEngine for PHP and CodeIgniter

The first steps will be to get a copy of the PHP SDK. It comes in different flavours: Linux, OS X and Windows. Check them out here. You will also get bundled a local python webserver, and an uploading tool.

Next, we’ll get the latest version of the CodeIgniter framework directly from GitHub (2.1.4 will be used for this post) Link here.

Putting everything together

To allow an application to run on AppEngine, we need to create app.yaml file in the root directory of the application.

application: codeigniter-dev
version: 1
runtime: php
api_version: 1
threadsafe: false

- url: /favicon.ico
  static_files: /favicon.ico
  upload: /favicon.ico
  expiration: 30d

# make the user_guide a static dir!
# you dont need to include it in every project you make
- url: /user_guide
  static_dir: user_guide

- url: /.*
  script: index.php

codeigniter-dev is our application name and you’ll need to change it by the one you have chosen for your application before uploading it.

After this first configuration step, we can launch the application by using the Local Web server included in the App Engine SDK, or we could just use our preferred Web Server (In my case, I run a local LAMPP environment.

First upload to Google App Engine

If you don’t have done it before, we invite you to create an App Engine application ( and to subscribe to the App Engine for PHP beta program ( in order to allow the upload of a PHP application to your App Engine instance. Indeed, the PHP runtime that has been announced at the last Google I/O conference is still in beta and Google authorizes progressively its roll out.

We then upload the application to the App Engine using the following command that you need to adapt to your environment:

../google_appengine/ -R --oauth2 update ./

And the answer is:

11:26 AM Host:
11:26 AM Application: codeigniter-dev; version: 1
11:26 AM Starting update of app: codeigniter-dev, version: 1
11:26 AM Getting current resource limits.
11:26 AM Scanning files on local disk.
11:26 AM Cloning 184 application files.
11:26 AM Uploading 184 files and blobs.
11:26 AM Uploaded 184 files and blobs
11:26 AM Compilation starting.
11:26 AM Compilation completed.
11:26 AM Starting deployment.
11:26 AM Checking if deployment succeeded.
11:26 AM Deployment successful.
11:26 AM Checking if updated app version is serving.
11:26 AM Completed update of app: codeigniter-dev, version: 1

We then try to access the application through the url, and voilá, almost no hassles: Behold CodeIgniter natively working on Google AppEngine on

CodeIgniter almost working on Google App Engine

CodeIgniter almost working on Google App Engine

Just a small PHP warning saying that php_sapi_name() function isn’t working. I did a quick Google search, and it’s indeed disabled by default by Google, and it can be enabled by uploading a custom php.ini file:

google_app_engine.enable_functions = "php_sapi_name"

So I create the file, add just that line, re-upload, re-fresh the screen and:

Default CodeIgniter installation working on Google App Engine

Default CodeIgniter installation running natively on Google App Engine

It’s working and I’ll leave it this way for now. My next goal, which I’ll cover in future posts will be to thoroughly test each and every function!


20 thoughts on “CodeIgniter on Google AppEngine for PHP

  1. Pingback: CodeIgniter on Google AppEngine for PHP: The Logging Class | Programming 4 Design

    • So far I’ve been able to implement all the libraries I needed. I’m working on the Email library article (which gave me a few headaches) Thanks for the feedback Anthony!

  2. Pingback: Google App Engine คืออะไร | รับเขียนโปรแกรม เว็บไซต์ การบ้าน โปรเจคนักศึกษา

  3. Hi,

    your post is nice.
    i also tried CI GAE to navigate from page to another page but it seems that only the default controller are being rendered.


    from URL GET / -> goes to default controller as configured.
    to URL GET /users/register -> goes to default controller also

    my guess is that the problem is in this app.yaml

    – url: /.*
    script: index.php

    do you know how can i fix this.. i tried doing .htaccess but seems no luck…
    i even tried this one and not working…

    i can send you my sample app link… just pm me :)


    • @Chito I’m having the same problem you had where all of the controllers are going back to the main controller. I downloaded the same project from github but it’s still not working. What’s wierd is if I deploy it to GAE it works fine, all the controllers go where they’re supposed to go. This is making local development very difficult. Is there any chance you changed some configuration file or something to get it to work? Any more detail you could provide would be awesome.


  4. Pingback: Google App Engine PHP Runtime ora disponibile per tutti

  5. Pingback: Google App Engine PHP Runtime now available to everyone « « EsheleDEsheleD

  6. Pingback: Google APP Engine正式支持PHP了! | 信念

  7. Hi first of all thanks for your great tutorial.
    I follow your tutorial and successfully upload my project in app engine. But after deploy in google appengine the default page of codeigniter, when i click on “user guide” link it does not show any response.
    Am i missing something

  8. @Chito @Akash Islam
    The user_guide directory is not viewable, because I didn’t include it in the app.yaml file as I don’t use to upload it to my live sites.
    In order to see the directory you should include the following directive in your app.yaml file BEFORE the last url handler:

    # make the user_guide a static dir!
    – url: /user_guide
    static_dir: user_guide

    I’m editing this post to reflect this problem you’ve been having! Cheers

  9. Pingback: pinboard October 25, 2013 —

  10. Hi,

    How did you manage to handle the clean urls functionality of codeigniter as there is no mod_rewrite ?

    • Simon, I got it partially working by writing the routes in the app.yaml file and picking them up in the routes.php

      Still, A good regex in the app.yaml is needed to handle URLs and then the config/routes.php in CI to apply them. If I ever get enough time I’ll look into it.

  11. It can be really an incredible along with handy piece of info. I’m just content which you simply shared this handy details along with us. Be sure to keep people informed in this way. Appreciation for expressing.

  12. Hi, just tried this today and it works out of the box. I did not have to add php.ini with google_app_engine.enable_functions = “php_sapi_name” settings.


Leave a Reply

Your email address will not be published. Required fields are marked *