-
Notifications
You must be signed in to change notification settings - Fork 33
PHPStorm Integration
PHPStorm can be slow when indexing Totara project files due to the sheer amount of code we have. It can be made quicker by excluding some directories that we don't need from indexing.
You can add non-important files and directories to the list of exclusions by copying the contents of this file into your project's main .iml file,
which will be located at .idea/PROJECTNAME.iml
(e.g ~/totara-sites/integration/.idea/integration.iml
)
This can make the indexing of your project up to 30-40% faster.
- Install PHPUnit for your site as per these instructions.
- Go to PHPStorm settings (
Ctrl+Alt+S
), and go to PHP - Under CLI Interpreter, click the ... button
- Add an interpreter, selecting From Docker, Vagrant, VM, WSL, Remote...
- Select Docker Compose
- Under Server, click New and add a new Docker daemon using the relevant type for your OS then click OK
- MacOS: Rancher Desktop, or if you don't have Rancher, Docker Desktop
- Windows: Docker for Windows
- Linux: Unix socket
- Add Configuration files, with the files being: (in the following order)
totara-docker-dev/docker-compose.yml
, andtotara-docker-dev/compose/php.yml
(wheretotara-docker-dev
is the path of this docker-dev respository on your machine)
- Select a PHP container under Service, e.g. php-8.3-debug
- Click OK
- Untick Visible only for this project
- Set Lifecycle to Connect to existing container
- Your CLI interpreter should look something like this:
- Click OK
- For CLI Interpreter, select the interpreter you just added and click OK
- Under Path mappings, add a mapping for your local totara code directory, where Local Path =
LOCAL_SRC
and Remote Path =REMOTE_SRC
from your docker-dev.env
file.
- Go to PHP > Test Frameworks
- Add a test framework, selecting PHPUnit by Remote Interpreter
- Select the interpreter you added and click OK
- Set Path to script to be
/var/www/totara/src/SITENAME/test/phpunit/vendor/autoload.php
, whereSITENAME
is the name of your site's subdirectory (if you do not have multiple sites set up, this can be omitted). Note: For Totara 12 or older/Moodle, this will need to be/var/www/totara/src/SITENAME/vendor/autoload.php
- Set Default configuration file under Test Runner to be
/var/www/totara/src/SITENAME/test/phpunit/phpunit.xml
, whereSITENAME
is the name of your site's subdirectory (if you do not have multiple sites set up, this can be ommitted). Note: For Totara 12/Moodle or older, this will need to be/var/www/totara/src/SITENAME/phpunit.xml
You should now be able to run unit tests directly from within PHPStorm. If you set up XDebug as documented below, you will also be able to set breakpoints within in your tests too.
-
Ubuntu & Windows Only: Set the
HOST_IP
variable in your docker-dev.env
file to be172.17.0.1
- Go to PHPStorm settings (
Ctrl+Alt+S
), and go to PHP > Servers - Add a server, with the name being
totaraXX
(whereXX
= the PHP version, e.g.83
), the host beingtotaraXX.debug
, the port being80
, and the debugger beingXdebug
. If you have multiple sites set up with subdomains, you can set the host to beSITENAME.totaraXX
- Tick Shared (next to Name)
- Tick Use path mappings, and set the absolute path on the server to be
/var/www/totara/src
(or/var/www/totara/src/SITENAME
if you have multiple sites set up)
XDebug should now work and PHPStorm will listen and activate breakpoints when the Start Listening for PHP Debug Connections setting is enabled.
You can trigger your breakpoints when visiting http://SITENAME.totaraXX.debug/
pages in your browser, or when running unit tests within PHPStorm (if you are using a totaraXX.debug
host), or when running a PHP script while in a php-X.X-debug
container.
-
In the database tool pane, add a new database and select the DBMS you wish to view (e.g. PostgreSQL or MySQL) under Data Source
-
Set the Host to be
localhost
-
Set the Port, User and Password values to be the same as what is listed in this table
-
Download Drivers if they are missing
- Under the Schemas tab, select the database schemas you want to be able to view (or select All schemas_)
- Click OK
- Click Refresh in the Database panel
You should now be able to view tables and use the database console for the DBMS you added.
Copyright (c) 2025 Totara Learning Solutions Limited
-
MailDev (for viewing emails)
-
Ngrok (for making your site publicly accessible)
-
PHPStorm Integration
- Performance improvements
- Automated testing integration
- XDebug setup
- Database tools