Support of Google App Engine for PHP integration has been removed since version 2018.1. Please see more details at https://youtrack.jetbrains.com/issue/WI-41422#comment=27-2800889 .
In this tutorial we'll create a simple Google App Engine PHP application with PhpStorm IDE.
Watch this video on Support for GAE PHP in PhpStorm.
Make sure that the following software is downloaded and installed:
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.
Important! Sign in to your Google Account, and get the application id if you are going to upload (deploy) your application to Google App Engine.
‘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.
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:
PhpStorm generates the following structure, which we can explore in the Project tool window:
Besides that, PhpStorm also generates two files:
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.
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.
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:
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:
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!