appengine ja night #25 Google App Engine for PHP (English)


Published on

This is a slide about 'Google App Engine for PHP' written in English.
I wrote it for the developer event named "appengine ja night" in Japan.

And I added some contents which I spoke in the event to this slide.
Therefore, the English version is written in more detail than Japanese version.

Unfortunately, I'm not good at English. (I'm studying English now)
But I think that it is more readable than Japanese for many people.

Please tell me if you find mistakes (in the point of English or Technology).

- Japanese Version

Published in: Technology, News & Politics
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

appengine ja night #25 Google App Engine for PHP (English)

  1. 1. Google App Engine for PHP appengine ja night #25 Ryo Yamasaki @vierjp 1
  2. 2. •  Blog • •  Twitter •  @vierjp •  Work •  I mainly develop server side applications by Java. (Sorry, I’m newbie of PHP.) •  I was a technical leader for the smart phone service provider company in the previous job. •  I had used the products of Google Cloud Platform, such as App Engine, Cloud Storage and BigQuery. •  Publishing Android apps •  WiFi Tunes Sync •  WiFi Tunes Sync Pro Ryo Yamasaki Self Introduction 2
  3. 3. Google App Engine for PHP 3 Agenda 1.  Overview of GAE/PHP 2.  Updating after Google I/O 3.  IDE for GAE/PHP 4.  Deploying existing applications 5.  Notes of deploying existing applications 6.  How to use CakePHP on GAE/PHP
  4. 4. Google App Engine for PHP 4 Overview
  5. 5. Google App Engine for PHP •  PHP was added •  It was announced on May 15th 2013 at Google I/O •  Now Limited Preview (You can apply for it) •  PHP Version 5.4.8 •  You can use Cloud SQL •  You (maybe) can use Cloud Datastore API Overview 5
  6. 6. Google App Engine for PHP •  App Engine Ver.1.8.1 •  mbstring (Multibyte String Functions) added. •  mcrypt (Encryption Functions) added. •  iconv (Character encodings conversion) added. •  Including script files from Google Cloud Storage Updating after Google I/O (1) 6
  7. 7. Google App Engine for PHP •  How to include PHP scripts from Cloud Storage Updating after Google I/O (2) 7 <?php require_once "gs://my_bucket/file.php"; google_app_engine.allow_include_gs_buckets = "my_bucket" •  php.ini
  8. 8. Google App Engine for PHP 8 IDE for GAE/PHP
  9. 9. Google App Engine for PHP •  The popular PHP IDE for PHP developers •  Supporting GAE / PHP •  You can debug and deploy with the IDE. •  You can use this for free for a month. PhpStorm 9
  10. 10. Google App Engine for PHP PhpStorm : Debug 10
  11. 11. Google App Engine for PHP PhpStorm : Deploy 11
  12. 12. Google App Engine for PHP 12 Deploying existing applications
  13. 13. Google App Engine phpinfo 13 •  View information environment of PHP •  Server Configuration •  PHP extensions
  14. 14. Google App Engine Word Press Ver.3.5.1 (Japanese Version) 14 •  No problem on posting and displaying in Japanese. •  The WordPress plugin for GAE/ PHP has been provided.
  15. 15. Google App Engine for PHP •  You can upload Files. •  You can receive emails when someone comments on your posts. •  UI for some there was a problem is corrected. WordPress plugin for GAE/PHP (provided by Google) 15
  16. 16. Google App Engine for PHP 1.  WP Multibyte Patch This is included in Japanese Version. And this plugin depends on mbstring. 2.  Memcached Object Cache 3.  Batcache 4.  Wptouch 5.  FancyBox 6.  WP Social Bookmarking Light 7.  Secure WordPress 8.  Crazy Bone I tried some WordPress Plugins 16
  17. 17. Google App Engine phpMyAdmin Ver.4.0.3 17 •  Management tools for MySQL
  18. 18. Google App Engine for PHP •  WordPress •  List of Articles •  Article detail •  Posting an article and an image •  Plugin •  Access from smartphones Demo : WordPress 18
  19. 19. Google App Engine for PHP 19 Notes of deploying existing applications
  20. 20. Google App Engine •  Limitation of GAE / PHP •  Applications can't write to the local file system. •  They need to use Cloud Storage instead of the local file system. •  On GAE/PHP, you can't upload files in a standard way of PHP. •  Can not be used to '$_FILES' in a general way. •  You must upload directly to Cloud Storage. •  Can not be used functions that operate the System or Process. •  Developers can’t add PHP extensions. Notes of deploying existing applications 20
  21. 21. Google App Engine for PHP 1.  The I/O to the file system •  You need to change the path of the file to write to Cloud Storage path. •  However, there is some cases to cause problems by simply changing the path. •  (It mentions later in detail.) 2.  File uploading function •  You need to change upload process to the unique way of GAE / PHP. •  See: 3.  Logging function •  Using ‘syslog’ function. •  Thereby, you can see the logs on the Admin Console of App Engine. 4.  Session Management •  The session data is written to only Memcache by default. •  Therefore, the session data might disappear suddenly. •  This problem can be solved by implementing your own session handler using other data storage,such as Google Cloud SQL. •  See: 5.  Sending email function (It mentions later in detail.) 6.  Required PHP extensions •  Developers can’t add PHP extensions. Notes of deploying existing applications 21
  22. 22. Google App Engine for PHP •  Basically, it is possible to read and write files with the standard PHP function if you change the path to the pass of Cloud Storage. •  Accessing to files and directories on Cloud Storage is processed using “Stream Wrapper (function of PHP) ”. •  Behavior of operations on the directory is doubtful.(Issue:9368) •  Checking existence of directory •  Creating Directory •  etc. •  Problems may occur if the existing code use specific functions. •  ‘realpath’ function (Stream Wrapper is not support this function.) The supplementary note about File I/O 22
  23. 23. Google App Engine for PHP •  The 'mail' function of PHP doesn't seem to work. •  An error occurred. “The function mail is not implemented. “ •  It is not documented. •  The plugin for WordPress sends emails in the following way. The supplementary note about sending email 23 require_once 'google/appengine/api/mail/Message.php'; use googleappengineapimailMessage; // Use the class for App Engine’s MailService. $mail = new Message(); // Now MailService doesn’t support view name of ‘From Address’. // ( It is written in comment of the WordPress Plugin.) //$mail->setSender(' Ryo Yamasaki <>'); $mail->setSender( '’ ); $mail->addTo( ’’ ); $mail->setSubject( 'Test Subject' ); $mail->setTextBody( 'Test Message' ); // Send ! $mail->send(); This code has been simplified.
  24. 24. Google App Engine for PHP 24 How to use CakePHP on GAE/PHP
  25. 25. Google App Engine for PHP •  Googler wrote about conditions of frameworks for GAE/PHP on Issue Tracker.(Issue:9336) 1.  Not writing temporary files to the file system of GAE. 2.  Logging uses ‘syslog()’ function. How to use CakePHP on GAE/PHP 25
  26. 26. Google App Engine for PHP •  The default CakePHP write various files to the tmp directory of the app. How to use CakePHP on GAE/PHP 26 •  It caused an error. •  And an error was occurred at the checking existence of directory, even if I specified the path of Cloud Storage as the tmp directory.(Issue:9368)
  27. 27. Google App Engine for PHP •  CakePHP has mechanisms for switching the target of the I/O. 1.  I specified APC or Memcache as destination of temporary data. 2.  I specified syslog function as how to output log. (The code --SyslogLog.php-- is included in CakePHP 2.4.) 3.  I changed the storage location of session data into CloudSQL. (This is not required. But I recommend.) How to use CakePHP on GAE/PHP 27 * There are detailed codes on my blog and GitHub. This blog is written in Japanese. But, if you know CakePHP, you might be able to understand the code. Also, please try to the "Translate" where is right side of the blog page. If you have any questions, please contact me.(on Google+ or twitter)
  28. 28. Google App Engine for PHP •  You can not send emails with the standard code of CakeEmail. •  The ‘mail’ function doesn’t work. •  It isn't possible to socket communication with the SMTP server. •  It is possible to send by creating a class (the class called 'Transport') that uses the MailService, and switching to it. •  It is possible to attach to email static files that is included in the app. •  But modifying codes of CakeEmail is needed to attach the files which put on Cloud Storage. (because CakeEmail uses 'realpath' function.)   Cake/Email 28
  29. 29. Google App Engine for PHP 1.  Simple CRUD processing. (list, registration, edit, and delete) 2.  Authentication using UserService of App Engine. 3.  Only administrative users and posters can edit or delete. Demo : a sample application of CakePHP 29
  30. 30. Google App Engine for PHP •  Portability •  Existing applications work to some extent. •  Existing frameworks work if they match some conditions. •  If some functions become to work transparently, then GAE/PHP becomes even better. •  Uploading files •  Operation of files and directories against Cloud Storage •  Sending emails •  Scalability •  I think that if GAE/PHP becomes to be able to use Datastore as well as other languages, then it becomes even better. Summary 30
  31. 31. Google App Engine •  Google App Engine for PHP Limited Preview (Here, you can apply for GAE/PHP) • •  Google App Engine for PHP (Official Documents) • •  Tips and tricks from the Google App Engine PHP team • •  PHP IDE :: JetBrains PhpStorm • •  Getting Started with PhpStorm as Google App Engine PHP IDE • •  WordPress › 日本語 (Japanese Version) • •  WordPress › Google App Engine for WordPress « WordPress Plugins • •  Google Cloud Datastore (Official Documents) • 31 Related URLs.
  32. 32. Google App Engine •  27.Google I/Oで発表されたCloud Platformの新機能 • •  28.Google App Engine for PHP (GAE/PHP) を早速試してみた • •  29.Google App Engine for PHPで WordPress を動かしてみた • •  30.Google App Engine for PHPにおけるポータビリティを考える • •  36.Google App Engine for PHPで WordPress を運用するためのプラグイン • •  39.Google App Engine for PHP で CakePHP を動かしてみた • •  33.Google Cloud Datastoreを試してみた 概要編 (1/3) • 32 Related My Blog URLs.
  33. 33. Thanks for your reading! @vierjp Google App Engine for PHP