Setting up a data source is a very simple process when PhpStorm knows where to find your Joomla configuration as explained in the PhpStorm and the Joomla! configuration file blog. PhpStorm will read the database connection details from the Joomla configuration file and create the data source.
To create a data source we first need to open the database tool window. Usually the Database window is located on the left or right sidebar. In case the Database window is not shown on the sidebar, there are several ways of achieving this.
Opening the Database window using the menu
- Click on View
- Select Tool Windows
- Click on Database
- The Database window will open up on the right sidebar
Opening the Database window using Find Action...
- Hit CTRL-SHIFT-A / CMD-SHIFT-A to open the Find Action window
- Type Database
- Hit Enter or double click on the first Database
- The Database window will open up on the right sidebar
Creating a Data Source
To create a Data Souce we will follow these steps:
- Click on the + symbol to open the menu
- Select the Import from sources... option
- PhpStorm will open the Data Source and Drivers page
- On the General tab all details are filled in with the settings from the Joomla Configuration file
- Give the Data source a name, this is by default filled with joomla.datasource
- Click on Test Connection to see if all details are correct
- Click OK to save the data source
- The Database window now has the database setup
You now have access to your database directly from PhpStorm.