Software Coding

Install CakePHP 2.7.9 on Google App Engine


I build apps on GAE using Codenvy from a Chromebook, so I need a process for CakePHP installation that can be done without a local webserver and without using Composer. I am much indebted to my colleague Murshed Ahmmad Khan and this excellent but perhaps a bit outdated post by M.J. McConnell to figure this all out. Here are the steps to load a clean release.

  1. Create the project on GAE, with the MySQL instance your_sql:your_instance
  2. Create the storage bucket named your_app.appspot.com including verifying to Google that you control that domain by following all the steps to upload the special googlennnnnnn.html file into my app/webroot/files folder, and deploy it to serve on your app with the lines:
     - url: /googlennnnnnnn.html
       static_files: app/webroot/files/googlennnnnnnn.html
       upload: app/webroot/files/googlennnnnnnn.html
  3. Download the source zip file from https://github.com/cakephp/cakephp/releases
  4. Upload the zip file to Codenvy, telling it to exclude the root folder when it unpacks it.
  5. Edit app.yaml like the example below.
  6. Create a php.ini file as shown below.
  7. Follow the instructions at this link to download DebugKit from https://github.com/cakephp/debug_kit and install it into the app/Plugin folder (not the “plugins” folder in the root area) using Option A (download) for Step 1. Tell it to NOT exclude the root folder, which you need. Edit the bootstrap.php folder uncomment the “CakePlugin::loadAll(); ” line to ensure you’ve got DebugKit loaded no matter what the name of the folder is (on mine, it was debug_kit-master).
  8. Make a batch of edits to Config/core.php to change how storage and logs are handled:
    1. Change the $engine assignment to be $engine = ‘Apc’;
    2. Change the Configure::write commands for Error and Exception for ‘log’ from ‘true’ to ‘false’
  9. Edit Config/bootstrap.php:
    1. Change the default cache line to read Cache::config(‘default’, array(‘engine’ => ‘Apc’));
    2. Change the final two sections on logging to use Syslog instead of Filelog.
  10. Edit webroot/index.php by adding these lines at the top.
    session_start();
    //Change the default TMP Folder path to a Cloud Storage Bucket
    if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
     define('TMP', "gs://your_app.appspot.com/");
    }
  11. You can now run it — you’ll see errors about fixing the security.salt and security.seed in core.php. Obey those commands. By visiting http://www.sethcardoza.com/tools/random-password-generator/ to get good random alphanumeric and numeric strings.
  12. Next – rename Config/database.php.default to Config/database.php, ignore the host setting and add the line ‘unix_socket’ => ‘/cloudsql/your_sql:your_instance’
  13. Bake the Cake! You cannot run the command line utilities to automatically generate your scripts, but you can use a wonderful online tool that will generate the Model, View and Controller files you need in ready-to-upload zip folder at http://patisserie.keensoftware.com/.

Contents of php.ini

; Enable php core functions
google_app_engine.enable_functions = "php_sapi_name, php_uname, gc_enabled"
; Load Google Cloud Storage Buckets here
google_app_engine.allow_include_gs_buckets = "your_app.appspot.com"
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT

Contents of app.yaml

application: your_app
version: 1
runtime: php55
api_version: 1
threadsafe: yes
handlers:
- url: /css
  static_dir: app/webroot/css
- url: /js
  static_dir: app/webroot/js
 
- url: /img
  static_dir: app/webroot/img
- url: /favicon\.ico
 static_files: app/webroot/favicon.ico
 upload: app/webroot/favicon\.ico
- url: /.*
  script: app/webroot/index.php
  login: required
- url: .*
  script: app/webroot/index.php
  login: required

 

1 thought on “Install CakePHP 2.7.9 on Google App Engine”

Comments are closed.