The license could not be verified: License Certificate has expired!
Make sure that the following software is downloaded and installed:
- Google App Engine SDK for PHP
- Python version 2.7
- php-cgi 5.4 with the relevant modules
- MySQL (for applications that work with databases)
Explore the requirements to the development environment and installation instructions here.
Following environment configuration tutorials provided by Google you should be able to run “hello world” test application locally via commandline at this point.
2. Installing ‘Google App Engine Support for PHP’ Plugin
‘Google App Engine Support for PHP’ plugin should be installed in PhpStorm to get a support for Google App Engine PHP. Just invoke Configure | Plugins from the welcome screen or File | Settings (PhpStorm | Preferences on Mac OS X) or press Ctrl+Alt+S / cmd , or Settings Icon and navigate to Plugins section.
Press ‘Install JetBrains plugin..’ and select ‘Google App Engine Support for PHP’ in the list. Download and install the plugin via context menu or download and install button .
Restart of the IDE will be offered at this point - it is required to activate the plugin.
3. Creating the First Google App Engine PHP Application
Let's start with creating a simple Google App Engine PHP application - the inevitable "Hello, world" - from scratch. Creating a new project is easy: just choose File | New Project in the main menu, or click Create New Project on the welcome screen.
A New Project window will be shown - enter project name (ps-integration-testing in our case) and select its type — App Engine Project:
On the next step we need to provide some additional information, such as:
- Application ID (it should be got from Google App Engine, signing in to Google Account is required)
- SDK directory (directory should contain dev_appserver.py and ‘google’ and ‘php’ packages)
- Python executable (Python 2.7)
PhpStorm generates the following structure, which we can explore in the Project tool window:
Besides that, PhpStorm also generates two files:
- app.yaml which defines the runtime environment, API version, and a reference to the handler, which will be executed
- the default request handler main.php
We can change Google App Engine for PHP settings in Settings | Project Settings | Google App Engine for PHP. SDK directory and Python executable paths can be changed here, also we can provide Google Account credentials for deployment (in case we leave it empty here we will be asked to provide it before uploading the application to Google App Engine).
Another option to begin with exploring Google App Engine for PHP is opening an example application provided by Google. Go to File | Open Directory and select the example you would like to check. In this case SDK directory and Python executable paths should be provided in Settings | Project Settings | Google App Engine for PHP.
4. Creating Contents
If we look into main.php, we will see that "Hello world!" is already there. The default handler and configuration is provided in app.yaml.
All the various coding assistance features available in the IDE are available: syntax and error highlighting, automatic indentation, code completion, and more. Google App Engine SDK directory is automatically added to Libraries in PhpStorm so all the APIs and classes available there will be used for code assistance.
5. Running Application Locally
Our application is ready. Before uploading it to Google App Engine space, let's try to launch it locally. For this purpose, PhpStorm provides run/debug configuration. Have a closer look at it: on the main toolbar, click the run/debug configuration selector (which now shows ps-integration-testing), and choose Edit Configurations...:
The Run/Debug Configurations dialog box shows the configuration, which PhpStorm has generated automatically. The only one thing we need to do here for now is providing path to php-cgi executable.
We can also change server configuration, command line options and set up some tasks to run before launch.
Next, press Shift+F10 / ^R or click Run button on the main toolbar and observe application's output in browser by the server address (by default the address is http://localhost:8080).
Run pane will show the output of GAE application server we just run:
6. Debugging Application Locally
We can also debug our Google App Engine PHP application locally with PhpStorm. Put a breakpoint in the application and press Shift+F9 / ^D or click Debug button on the main toolbar and then open the application in the browser (by default the address is http://localhost:8080).
Console tab of Debug pane will show the output of GAE application server we just run with Debug action:
The application will stop on every breakpoint as usual, Debugger tab of Debug pane will show all the necessary debugging information:
7. Uploading (Deploying) the Application to Google App Engine PHP
We are now sure that the application works properly, and can deploy (upload) it to the Appspot (Google App Engine space).
In the Tools menu, point to Google App Engine for PHP node, and choose Upload App Engine PHP app:
In the App Engine Account dialog box, sign in to the Google Account (if credentials haven’t been saved in Settings before). PhpStorm runs appcfg.py, and displays output in the appcfg.py tab of the Run tool window:
That’s all! The application is successfully uploaded to Google App Engine. Visit Google Account, and see it running!