Software Coding

Install CakePHP 3.1.x on Google App Engine


[Under Construction 1/29/16] Doing a clean install on GAE for Cakephp3 starts out quite similar to Cakephp2 (see prior blog here.) I will therefore just reference the difference to those points.

  • Skip step 7 installing DebugKit — it’s built into the Cakephp3!
  • Step 8 is similar, but the Apc is now named ApcCache. You do not need to changing logging or exception handling
  • Step 9 and 10 are totally different. No changes are needed to config/bootstrap.php or webroot/index. Instead, the file config/paths.php changes two lines to make tmp/ and logs/ writeable in the application cloud storage bucket.
/**
 * Path to the temporary files directory.
 */
define('TMP', 'gs://your_app.appspot.com/');
/**
 * Path to the logs directory.
 */
define('LOGS', 'gs://your_app.appspot.com/');

 

  1. app.yaml should be set up to the completely different folder arrangement of 3.1

version: 1
runtime: php55
api_version: 1

handlers:
– url: /css
static_dir: webroot/css

– url: /js
static_dir: webroot/js

– url: /img
static_dir: webroot/img

– url: /favicon.ico
static_files: webroot/favicon.ico
upload: webroot/favicon.ico

– url: /.*
script: webroot/index.php

– url: /debug_kit/css
static_dir: vendor/cakephp/debug_kit/webroot/css

– url: /debug_kit/js
static_dir: vendor/cakephp/debug_kit/webroot/js

– url: /debug_kit/img
static_dir: vendor/cakephp/debug_kit/webroot/img

 

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 = “thpgfr.appspot.com”
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT

extension=”intl.so”

Edit config/bootstrap.php only to tell it to log to Syslog

Log::config(‘default’, array(‘engine’ => ‘Syslog’));

Edit config/app.php to do caching via ApcCache in three places

‘Cache’ => [
‘default’ => [
‘className’ => ‘ApcCache‘…

‘Datasources’ => [
‘default’ => [
‘className’ => ‘Cake\Database\Connection’,
‘driver’ => ‘Cake\Database\Driver\Mysql’,
‘persistent’ => false,
‘host’ => ‘localhost,
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
‘unix_’ => ‘/cloudsql/yoursql:yourinstance’,
‘username’ => ‘root’,
‘password’ => ”,
‘database’ => ‘yourdb’,
‘encoding’ => ‘utf8’,
‘timezone’ =>’UTC’,