Download - Deploy a PHP App on Google App Engine
![Page 1: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/1.jpg)
Deploy !a PHP Application!on Google App Engine
![Page 3: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/3.jpg)
PHP for App Engine
https://developers.google.com/events/io/sessions/333055646
![Page 4: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/4.jpg)
The GAE platform
Platform as A Service (PaaS)!
Build, deploy & scale!
Don’t care about infrastructure
https://appengine.google.com/https://developers.google.com/appengine/
![Page 5: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/5.jpg)
Google App Engine: services
All PaaS have limitations!
PHP is in preview phase!
Not all services are available
https://developers.google.com/appengine/features
![Page 6: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/6.jpg)
Google App Engine: data storage
Google Cloud Sql !
Memcache!
Google Cloud Storage
![Page 7: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/7.jpg)
Google App Engine: ext services
Email (internal or SendGrid)!
Twilio!
UrlFetch
![Page 8: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/8.jpg)
Google App Engine: offline work
TaskQueue!
Cron
![Page 9: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/9.jpg)
Google App Engine: auth
User Auth!
Application Identity
![Page 10: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/10.jpg)
PHP on GAE
![Page 11: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/11.jpg)
PHP 5.4!
Runs in a sandbox
https://developers.google.com/appengine/docs/php/
PHP on GAE
![Page 12: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/12.jpg)
Some well-know extension are disabled: imagick, intl, pcntl, curl
PHP on GAE
![Page 13: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/13.jpg)
Some well-know extension are disabled: imagick, intl, pcntl, curl
PHP on GAE
whaaat?
![Page 14: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/14.jpg)
Some function are disabled!
permanently: exec, tmpfile!
partially: /e on preg_replace!
softly: gc_*, parse_str
PHP on GAE
![Page 15: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/15.jpg)
File System is Read only: you can store files on Cloud Storage or external services
PHP on GAE
![Page 16: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/16.jpg)
PHP on GAE
![Page 17: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/17.jpg)
How to invoke external services (no curl remember? :-P)
PHP on GAE
![Page 18: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/18.jpg)
PHP on GAE
![Page 19: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/19.jpg)
Dynamic response max 32 MB!
Timeout on long response
PHP on GAE
![Page 20: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/20.jpg)
Sessions are stored on Memcache !
session_*, $_SESSION work as expected!
use session_set_save_handler to change handler
PHP on GAE
![Page 21: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/21.jpg)
Log are managed via syslog!
use PHP’s native syslog function!
use custom logging lib (eg. Monolog)
PHP on GAE
![Page 22: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/22.jpg)
PHP on GAE: DB
![Page 23: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/23.jpg)
PHP on GAE: sending mails
![Page 24: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/24.jpg)
get the sdk!
requirements: python 2.7, php-cgi, mysql?!
local web server
wget https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.4.zip
App Engine SDK
![Page 25: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/25.jpg)
# app.yaml application: propane-forge-391 version: 1 runtime: php api_version: 1 threadsafe: true
Base Config
![Page 26: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/26.jpg)
# app.yaml application: propane-forge-391 version: 2 runtime: php api_version: 1 threadsafe: true
Base Config
![Page 27: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/27.jpg)
# app.yaml — continued handlers: - url: /css static_dir: web/css - url: /js static_dir: web/js - url: .* script: web/index.php
Base Config
![Page 28: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/28.jpg)
# php.ini google_app_engine.enable_functions = “…”
Base Config
![Page 29: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/29.jpg)
!dev_appserver.py --php_executable_path=/usr/bin/php-cgi /
var/www/todo/ --host=gae.dev
Test Locally
![Page 30: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/30.jpg)
!dev_appserver.py --php_executable_path=/usr/bin/php-cgi /
var/www/todo/
Test Locally
![Page 31: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/31.jpg)
Deploy
!appcgf.py update /var/www/todo/!
(or git push)
![Page 32: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/32.jpg)
A kitchen sink app
https://github.com/ideatosrl/silex-todo-gae
![Page 33: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/33.jpg)
PHP on GAE: task queues
Execute offline work!
Expose endpoint(s) doing the work
![Page 34: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/34.jpg)
PHP on GAE: task queues
# queue.yaml
![Page 35: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/35.jpg)
PHP on GAE: task queues
![Page 36: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/36.jpg)
PHP on GAE: task queues
![Page 37: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/37.jpg)
PHP on GAE: task queues
# app.yaml
![Page 38: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/38.jpg)
PHP on GAE: cronjobs
Schedule repetitive tasks!
Expose endpoint(s) doing the work
![Page 39: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/39.jpg)
PHP on GAE: cronjobs
# cron.yaml
![Page 40: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/40.jpg)
PHP on GAE: cronjobs
# app.yaml
![Page 41: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/41.jpg)
PHP on GAE: users
![Page 42: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/42.jpg)
PHP on GAE: modules
![Page 43: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/43.jpg)
what we learned
integration is quite smooth for simple apps!!
some few common pattern
![Page 44: Deploy a PHP App on Google App Engine](https://reader035.vdocument.in/reader035/viewer/2022062406/558c88f9d8b42a014b8b459a/html5/thumbnails/44.jpg)
!apply to cloud.google.com/starterpack and get $ 500!
wanna try?