- Copy the
docroot/sites/default/example.services.local.yml
file todocroot/sites/default/services.local.yml
. - Clear the cache by running
ddev drush cr
. - Inspect the rendered page in a browser.
- You should see HTML comments indicating what templates are being used throughout the source code. See Drupal.org: Locating Template Files with Debugging
- Add
{{ drupal_dump() }}
,{{ drupal_dump(variable-name) }}
or{{ dd() }}
or{{ dd(variable-name) }}
to a Twig template file and refresh the browser with mass.local. See Drupal.org: Twig Tweak Cheat sheet (Drupal Dump) - You can add this multiple times to the same or different template files.
Remember to remove all calls to
drupal_dump()
ordd()
from templates before committing.
- Set up Xdebug in PhpStorm.
- Enable Xdebug in ddev by running
ddev xdebug on
. See DDEV PHP Step Debugging for ddev specific setup instructions and how to configure your IDE. - Download and enable the Xdebug helper browser extension.
- In PhpStorm, under Preferences > PHP > Frameworks:
- Check off
Enable Drupal integration
- Set
Drupal installation path
to[you_local_path_to_openmass_parent_folder]/openmass/docroot
- Select version
9
- Check off
- In PhpStorm, under Preferences > PHP > Servers, set
Absolute path on the server
to/var/www/html
for openmass. - Edit debug configurations:
For more information, refer to PHP frameworks and external tools/Drupal
- Enable the Devel module by running
ddev drush en devel
. - Clear the cache by running
ddev drush cr
. - Enable Xdebug listening in PhpStorm.
- Enable
Debug
in the Xdebug helper browser extension for the page you are debugging. - Set a breakpoint by clicking to the right of a line number in a PHP file.
- Refresh mass.local in the browser to hit the breakpoint.
Don't commit changes to the
core.extension
file enabling thedevel
module, ordevel
related config files.
-
Comment out
cache: false
indocroot/sites/default/services.local.yml
. -
Clear the cache by running
ddev drush cr
, and make sure openmass/docroot/sites/default/files/php/twig folder exists. -
In PhpStorm, under Preferences > PHP > Debug > Templates > Twig Debug, set the Cache path to
[you_local_path_to_openmass_parent_folder]/openmass/docroot/sites/default/files/php/twig
, or use the file locator to point to that folder. -
Set a breakpoint by clicking to the right of a line number in a Twig template file.
Please note: this method is not working consistently. Refer to the quickest debug method for Twig template logging for now. If you can get this the Twig debug working consistently with Xdebug, please suggest changes to these steps.
In order use xdebug with Drush in PHPStorm follow this steps:
ddev xdebug on
ddev ssh
export PHP_IDE_CONFIG="serverName=mass.local"
exit
- Start listening for PHP Debug Connections in PHPStorm
Switchto
.
- Set the break point in your PHP code.
- Execute the Drush command with
--xdebug
parameter, for exampleddev drush status --xdebug
. See more here. - For debugging purposes, if you can't get xdebug work with drush, set check "Break at the first line in PHP scripts" in PHPStorm Settings > PHP > Debug.
- Make sure "Ignore external connections through unregistered server configurations" is unchecked.