This document discusses using Xdebug with PHPUnit for debugging PHP code and unit tests in Drupal 8. It provides instructions on installing and configuring Xdebug as a PHP extension, and configuring the PHPStorm IDE and browser. Examples are given for using Xdebug to debug code locally and remotely, as well as debugging unit tests by running them via the command line or directly in the browser. Special configurations for Xdebug are mentioned when debugging tests via the command line since the browser cookie is not available. Donations are also requested for a Movember fundraising team.
13. IDE configuration: Debug instance
Open Debug panel pressing F9 and select
Edit configuration
Add new PHP Remote Debug instance
Set the ide key (session id)
and server
14. Browser configuration
● The IDE needs an Id to start the debug
● The browser provides the Id (session_id)
● Chrome / Firefox extension to provide Id
○ Xdebug helper
15. Use case : Debug code (I)
Environment configuration:
● Drupal 8 installed in local
● XDebug installed in local
● PhpStorm configured with an instance
Use case:
● Add breakpoint in code
● Run debug mode
● Navigate to stop in the breakpoint
This is my day by day use of XDebug.
16. Use case : Debug code (II)
Environment configuration:
● Drupal 8 installed in remote environment (vagrant)
● XDebug installed in remote environment (vagrant)
● PhpStorm configured with a sync code to remote env.
Use case:
● Add breakpoint in code
● Run debug mode
● Navigate to stop in the breakpoint
This is @LuisGonRod day by day use of XDebug.
17. Use case : Debug code (III)
Question: What if @LuisGonRod and me want debug in the same remote
environment?
http://derickrethans.nl/debugging-with-multiple-users.html
19. Use case : Debug tests (I)
Environment configuration:
● Drupal 8 installed in local
● XDebug installed in local
● PhpStorm configured with an instance
Running test by using browser
● Activate module Testing
● Run test DrupalnodeTestsPageEditTest
Use case
● Add breakpoint in test code
● Run debug mode
● Run test and wait to stop in breakpoint
Sometimes never stop...at least for me
20. Use case : Debug tests (II)
Environment configuration:
● Drupal 8 installed in local
● XDebug installed in local
● PhpStorm configured with an instance
Running test by using Php cli
● Activate module Testing
● Run test using
○ run-tests.sh script
○ drush test-run
21. Use case : Debug tests - run-tests.sh (III)
XDEBUG_CONFIG="idekey=drupal8" sudo php core/scripts/run-tests.sh --php
/usr/bin/php --url http://local.drupal --class "DrupalnodeTestsPageEditTest"
For me it’s not working, right now :(
configuring the script using PhpStorm it works
22. Use case : Debug tests - run-tests.sh (IV)
● Go to debug configuration (F9)
● Add a Php Script instance
● Configure it
○ File: path to run-tests.sh
○ Arguments: The run-tests parameters
○ Environment variables: XDEBUG_CONFIG with idekey
23. Use case : Debug tests - drush test-run (V)
drush test-run --uri= local.drupal DrupalnodeTestsPageEditTest
24. ...And what about PHPUnit?
We can debug PHPUnit tests using Phpstorm adding a PHPUnit or PHPUnit on server
instance
25. what about PHPUnit and php cli?
We can run test through runt-tests.sh script or
php scripts/run-tests.sh --php /usr/bin/php PHPUnit
27. Do you know why we have moustache?
● Configuraciones especiales de Xdebug
● Si lanzamos los test por consola no tenemos
la cookie del navegador.
28. Movember and Drupal community
If you can, please, donate.
you won’t be the only one, maybe in that room
you find some moustaches in @jose_lakatos
@jsbalsera @penyaskito and @gloob
http://es.movember.com/en/team/1674337
http://es.movember.com/mospace/10983485