Date post: | 24-Jan-2015 |
Category: |
Technology |
Upload: | luis-atencio |
View: | 4,912 times |
Download: | 2 times |
on App Engine
PHP
byLuis Atencio7/10/13
Outline
• Intro– Overview– Match made in heaven– What this means for PHP developers– Environment– Drawbacks– Installation– Project Structure
•Storage
•Services
•Demos
Intro
Overview
• It is a platform for developing web applications hosted on Google managed data centers
•Scalable, distributed, elastic PaaS
•PHP support was announced at Google IO 2013
•Limited Preview
•Most voted App Engine ticket by developers
•Alternatives:– Create a new JVM language– Use Caucho Quercus– Implement and extend the Open Source PHP core
Match Made in Heaven
•PHP inherently scalable
•Thread-safe
•Stateless
•PHP allows you to code (prototype) rapidly
•App Engine allows you to deploy rapidly
•Google’s PHP CGI has support for APC cache, OpenSSL, OAuth, Memcache, and many more extensions
What this means for PHP Developers
•For Java developers since 2008
•Proven, reliable, and super scalable infrastructure
•Same infrastructure that Google uses for their own apps
•Another PaaS in the market (CloudFoundary, Heroku, etc)
•Cloud SQL (MySQL)
•PHPStorm support for GAE
PHP allows you to code rapidly, App Engine allows you to deploy
rapidly
Architecture
Environment
Note: you can provide your own php.ini and overwrite certain values
PHP 5.8.4 runtime
APC bcmath json gd ereg dom
date ctypefunctions PDO mcrypt openSSL SOAP
SPL memcache memcached gcs simplexml url_fetch
Stream Wrappers
•Used extensibly in App Engine to overload communication protocols
•Allows you to use native PHP functions such as fopen( ) and fread( )
•Built in with App Engine:
Protocol Description
http URL Fetch Service
https:// Secure URL Fetch Service
gs:// Read/write GCS
Installation
•Python 2.7– Used by the SDK’s runtime
•PHP 5.4.8 GGI with extensions
•App Engine PHP 1.8.1 SDK– Contains scripts for running a local version of GAE (dev_appserver.py)– Contains scripts for managing your instances in production (appcfy.py)
•MySQL 5.5
Project Structure
•Source files [/src]
•Static resources [.css, .js, .png]
• [optional] PHP.ini file
• [required] YAML file for configuration management– YAML Ain’t Markup Language– Alternative to configuration management for App Engine (appengine-web.xml, queue.xml,
cron.xml)– Human friendly data serialization standard for programming languages
•Basic Usage:– http://en.wikipedia.org/wiki/YAML#Language_elements
Storage
Cloud StorageCloud SQL
Cloud SQL [doc]
•Experimental Mode
•Out-of-the-box MySQL 5.5.31
•Automatic Backups (daily)
•Geo-located with your application
•Replicated across datacenters
SQL
Storage
Cloud StorageCloud SQL
Cloud Storage [doc]
•Experimental Mode
•Emulation of a file system in the cloud with automatic backups
•This is the file system your application will interact with
•With built in stream wrappers, access is seamless
Storage
ServicesLogs Mail Memcache URL Fetch
Users Task Queues
Logs [doc]
•Overridden of the syslog( ) native function
•Logs redirected to App Engine’s rolling log implementation
•Logs can be configured in the admin console, and downloaded with SDK tools
Mail [doc]
•App Engine allows you to send mail with attachements
•Overriden the mail( ) function to be directed to their MailService call
•Configure a user in your application to send make from
• In local development mode, mail( ) call prints the mail text to the logs
Memcache [doc]
•Uses a distributed, scalable, in-memory caching technology
•Very effective for query caching and object state sharing (up to 1 MB)
•App Engine uses it for session management
URL Fetch [doc]
•Used to communicate with other applications or restful services
•HTTP/1.1 compliant
•Requests are made using the overloaded stream wrappers for http and https
•Use native PHP calls such as file_get_contents( )
•Response size can be up to 32MB
Users [doc]
•Detect signed in Google users or any OpenID identifier
•User properties such as admin role, first name, last name, email, nickname, etc
•Specially useful if your application belongs to the Google marketplace
Task Queues [doc]
•Perform asynchronous, parallel work outside of the scope of the request
•Follows the “web hooks” and “unit of work” patterns
•App Engine allows Task queues to execute for 10 minutes
•Configured via a file called queue.yaml: name, retry limits, concurrent execution limit, etc
Drawbacks of App Engine
•PHP functions and system calls blacklisted, e.g. exec(), system()
•Access to file system is prohibited
•Direct socket creation is prohibited
•Support for outbound sockets disabled
•Request/response cannot exceed 60 sec
•You cannot stream data within a single request
•Pure PHP: you cannot compile and upload your own extensions
Uploading your Application
•You must have a Google account and request your Google account to be whitelisted
•You need to create a GAE application ID and request Google to whitelist your application here:
https://gaeforphp.appspot.com/
•Using the SDK (appcfy.py) you will be able to upload and manage your instances in production
•Source-to-Push deployment via Git
•With minimal configuration, WordPress runs on App Engine seamlessly– One caveat, no dynamic updating of plugins and core
•Concrete5 and Drupal also known to run on App Engine
CMS on App Engine
Stuff to look at
•https://developers.google.com/appengine/docs/php/
•http://www.youtube.com/watch?v=Qt1_atU_Qsg
•http://php-minishell.appspot.com/
•http://stackoverflow.com/questions/tagged/google-app-engine+php
•https://developers.google.com/appengine/articles/wordpress
•https://moodle.org/mod/forum/discuss.php?d=228830
•https://developers.google.com/appengine/docs/php/refdocs/
•http://blog.jetbrains.com/phpstorm/2013/05/support-for-google-app-engine-php-in-phpstorm/
•http://blog.boombatower.com/drupal-google-app-engine
Next meeting:
South Florida PHP User Group
07/17/1013
Miami