Today’s guest post comes from Maarten Balliauw, Technical Evangelist at JetBrains, the vendor of smart developer tools such as IntelliJ IDEA, PyCharm, PhpStorm, Android Studio and many more.

At JetBrains we are building tools that aim to enhance developers’ productivity by automating routine tasks and helping you concentrate on coding.

Our IDE for PHP, PhpStorm, provides seamless integration with Google App Engine for PHP — allowing you to locally develop, debug and deploy your PHP applications on Google App Engine. When testing your application locally, we also support full emulation of App Engine services through the App Engine Development server.

The following video shows how to get started with Google App Engine for PHP in PhpStorm. We also have a comprehensive tutorial which covers Google App Engine with PhpStorm in detail.

When creating Google App Engine applications in PHP using PhpStorm, chances are that you’ll also be using Google Cloud SQL to store data. For these next steps, we will have assumed you have created a Cloud SQL instance from the Google Cloud Console.

PhpStorm, as well as IntelliJ IDEA and PyCharm, provides database management tools (see the right-hand side of the IDE or hit Ctrl+Alt+A (Cmd+Alt+A on Mac) and search for “Database”). You can use these built-in tools to create new tables, run arbitrary SQL commands and insert, update and delete data.

Opening the database pane, you can create a new connection or Data Source. You’ll have to specify the JDBC database driver to be used to connect to our database. Since Google Cloud SQL supports native MySQL connections, we can use the standard MySQL connector and enter connection details.
Connecting to a Google Cloud SQL database using PhpStorm database tools
The JDBC driver to use is com.mysql.jdbc.Driver, the database URL will be jdbc:mysql://:3306/ where cloudsql_ip_address is the IP address of our Google Cloud SQL instance, and database_name is the name of the specific database on that instance to which you want to connect.

As for database credentials, you can create a root user password through the Google Cloud Console or manually create a new user through PhpStorm using the following SQL statement:

CREATE USER 'user_here'@'%' IDENTIFIED BY 'password_here';

You can now make use of these new credentials to connect to Google Cloud SQL and do things like create tables.

Creating a table in Google Cloud SQL using PhpStorm database tools
Now, from our PHP code, you can easily create a new connection to our Google Cloud SQL instance using PDO:
Connecting to a Google Cloud SQL database using PDO
Give it a try (a trial version is available for PhpStorm) and let us know your thoughts through the comments below.

-Contributed by Maarten Balliauw, Technical Evangelist, JetBrains