SlideShare a Scribd company logo
Xdebug with PHPUnit 
In Drupal 8
About me
Intro: XDebug 
Depuración en PHP: 
● print_r(), var_dump(), … 
● FirePHP 
● Kint , Krumo, Ladybug 
● phpdbg incluido ya en 5.6
Intro: XDebug 
● Debugging and profiling PHP extension 
● Show log trace information 
● Allow step by step debugging 
More info
Intro: XDebug - My experience 
I feel secure on my own!!! 
but 
It’s not the holy grail
Xdebug installation + configuration: 
PHP extension 
+ 
System configuration 
+ 
IDE configuration 
+ 
Browser configuration
Xdebug installation: PHP extension 
sudo apt-get install php5-xdebug 
http://xdebug.org/docs/install
Xdebug installation: System configuration 
/etc/php5/apache2/php.ini AND/OR /etc/php5/cli/php.ini 
● zend_extension="/usr/lib/php5/20121212/xdebug.so" 
● xdebug.remote_enable=1 
● xdebug.remote_host= IDE host 
● xdebug.remote_port="9000" 
● xdebug.profiler_enable=1 
● xdebug.profiler_output_dir="/tmp" 
● xdebug.idekey="drupal8"
How do we check it? 
Web: echo phpinfo();
Xdebug installation: How do we check it? 
Console (cli): php -v & php -i | grep remote
IDE configuration 
● Set Xdebug in PhpStorm 
● Add a Php remote debug / Php Unit instance 
in PhpStorm 
● Set session id (ide key)
IDE configuration: Set XDebug 
● Configure Php debug 
● Configure server
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
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
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.
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.
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
Use case : Debug code (III)
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
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
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
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
Use case : Debug tests - drush test-run (V) 
drush test-run --uri= local.drupal DrupalnodeTestsPageEditTest
...And what about PHPUnit? 
We can debug PHPUnit tests using Phpstorm adding a PHPUnit or PHPUnit on server 
instance
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
And now...what?
Do you know why we have moustache? 
● Configuraciones especiales de Xdebug 
● Si lanzamos los test por consola no tenemos 
la cookie del navegador.
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

More Related Content

PDF
Automated testing in Drupal
PPTX
Automation testing with Drupal 8
PDF
Test all the things! Automated testing with Drupal 8
PPT
Zend Framework 2 - PHPUnit
PDF
Profiling PHP with Xdebug / Webgrind
PPT
JavaScript Unit Testing
PDF
Fuzzing - Part 2
PDF
Web Exploitation
Automated testing in Drupal
Automation testing with Drupal 8
Test all the things! Automated testing with Drupal 8
Zend Framework 2 - PHPUnit
Profiling PHP with Xdebug / Webgrind
JavaScript Unit Testing
Fuzzing - Part 2
Web Exploitation

What's hot (20)

PDF
PDF
PDF
Diagnosing WordPress: What to do when things go wrong
PPT
Js unit testing
PDF
Module, AMD, RequireJS
PPT
GTAC Boosting your Testing Productivity with Groovy
ZIP
Browser-Based testing using Selenium
PDF
TDD for Javascript developers
PDF
cf.Objective() 2017 - Design patterns - Brad Wood
PDF
Grooscript greach 2015
PDF
Backbone.js
PDF
淺談 Groovy 與 AWS 雲端應用開發整合
PDF
Grooscript gr8conf 2015
PDF
Lviv 2013 d7 vs d8
PPTX
Who’s afraid of WinDbg
PDF
Efficient JavaScript Unit Testing, May 2012
PPTX
Debugging NET Applications With WinDBG
PDF
Developing large scale JavaScript applications
PPTX
Taiko presentation
PDF
One step in the future: CSS variables
Diagnosing WordPress: What to do when things go wrong
Js unit testing
Module, AMD, RequireJS
GTAC Boosting your Testing Productivity with Groovy
Browser-Based testing using Selenium
TDD for Javascript developers
cf.Objective() 2017 - Design patterns - Brad Wood
Grooscript greach 2015
Backbone.js
淺談 Groovy 與 AWS 雲端應用開發整合
Grooscript gr8conf 2015
Lviv 2013 d7 vs d8
Who’s afraid of WinDbg
Efficient JavaScript Unit Testing, May 2012
Debugging NET Applications With WinDBG
Developing large scale JavaScript applications
Taiko presentation
One step in the future: CSS variables
Ad

Viewers also liked (19)

ODP
D8 configuration migration
ODP
Dcmi v likin kyiv 2013
PPT
Продвинутый мультисайтинг
PPTX
Managing Drupal on Windows with Drush
PDF
Drush installation guide
PDF
Drush workshop
PDF
[Srijan Wednesday Webinar] Mastering Drupal 8 Development with Drupal Console
PPTX
Drupal, Memcache and Solr on Windows
PDF
Getting started with Drupal 8
PPTX
Drupal 6 to Drupal 8 Migration
PDF
Composer tools and frameworks for drupal.ppt
PDF
Drush for humans - SANDcamp 2013
ODP
Drush Presentation
PPT
Drush and drupal. администрирование. Волчек Михаил
PDF
Composer Tools & Frameworks for Drupal
KEY
Depolying Drupal with Git, Drush Make and Capistrano
PDF
Drush - use full power - DrupalCamp Donetsk 2014
PDF
[drupalday2017] - DevOps: strumenti di automazione per Drupal8
PPT
5 Important Tools for Drupal Development
D8 configuration migration
Dcmi v likin kyiv 2013
Продвинутый мультисайтинг
Managing Drupal on Windows with Drush
Drush installation guide
Drush workshop
[Srijan Wednesday Webinar] Mastering Drupal 8 Development with Drupal Console
Drupal, Memcache and Solr on Windows
Getting started with Drupal 8
Drupal 6 to Drupal 8 Migration
Composer tools and frameworks for drupal.ppt
Drush for humans - SANDcamp 2013
Drush Presentation
Drush and drupal. администрирование. Волчек Михаил
Composer Tools & Frameworks for Drupal
Depolying Drupal with Git, Drush Make and Capistrano
Drush - use full power - DrupalCamp Donetsk 2014
[drupalday2017] - DevOps: strumenti di automazione per Drupal8
5 Important Tools for Drupal Development
Ad

Similar to Xdebug and Drupal8 tests (PhpUnit and Simpletest) (20)

PPTX
Drupal Development w/ PhpStorm and Xdebug
PDF
Xdebug as a Drupal debugging tool
PDF
Debugging PHP With Xdebug
PDF
Getting Started With Xdebug
PDF
Debugging PHP with Xdebug - PHPUK 2018
PDF
Debugging PHP with xDebug inside of Eclipse PDT 2.1
PDF
X-Debug in Php Storm
ODP
Using PHP IDEs with Drupal (DrupalDevDays Szeged 2014)
PPTX
Php unit for drupal 8
PDF
Debugging Drupal with Xdebug
ODP
Xdebug for Beginners
PDF
Test your modules
PPTX
Xdebug - Your first, last, and best option for troubleshooting PHP code
PPTX
DDD (Debugger Driven Development)
PDF
Modernize Your Drupal Development
PPTX
Xdebug
PDF
Introduction to Xdebug
PDF
Drupal 8 improvements for developer productivity php symfony and more
PPTX
XDebug For php debugging
PPTX
Drupal Development Tips
Drupal Development w/ PhpStorm and Xdebug
Xdebug as a Drupal debugging tool
Debugging PHP With Xdebug
Getting Started With Xdebug
Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with xDebug inside of Eclipse PDT 2.1
X-Debug in Php Storm
Using PHP IDEs with Drupal (DrupalDevDays Szeged 2014)
Php unit for drupal 8
Debugging Drupal with Xdebug
Xdebug for Beginners
Test your modules
Xdebug - Your first, last, and best option for troubleshooting PHP code
DDD (Debugger Driven Development)
Modernize Your Drupal Development
Xdebug
Introduction to Xdebug
Drupal 8 improvements for developer productivity php symfony and more
XDebug For php debugging
Drupal Development Tips

Recently uploaded (20)

PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
medical staffing services at VALiNTRY
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Nekopoi APK 2025 free lastest update
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
top salesforce developer skills in 2025.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Transform Your Business with a Software ERP System
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
System and Network Administraation Chapter 3
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
Which alternative to Crystal Reports is best for small or large businesses.pdf
medical staffing services at VALiNTRY
VVF-Customer-Presentation2025-Ver1.9.pptx
Nekopoi APK 2025 free lastest update
Navsoft: AI-Powered Business Solutions & Custom Software Development
top salesforce developer skills in 2025.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Design an Analysis of Algorithms II-SECS-1021-03
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
L1 - Introduction to python Backend.pptx
Transform Your Business with a Software ERP System
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
System and Network Administraation Chapter 3
How to Choose the Right IT Partner for Your Business in Malaysia

Xdebug and Drupal8 tests (PhpUnit and Simpletest)

  • 1. Xdebug with PHPUnit In Drupal 8
  • 3. Intro: XDebug Depuración en PHP: ● print_r(), var_dump(), … ● FirePHP ● Kint , Krumo, Ladybug ● phpdbg incluido ya en 5.6
  • 4. Intro: XDebug ● Debugging and profiling PHP extension ● Show log trace information ● Allow step by step debugging More info
  • 5. Intro: XDebug - My experience I feel secure on my own!!! but It’s not the holy grail
  • 6. Xdebug installation + configuration: PHP extension + System configuration + IDE configuration + Browser configuration
  • 7. Xdebug installation: PHP extension sudo apt-get install php5-xdebug http://xdebug.org/docs/install
  • 8. Xdebug installation: System configuration /etc/php5/apache2/php.ini AND/OR /etc/php5/cli/php.ini ● zend_extension="/usr/lib/php5/20121212/xdebug.so" ● xdebug.remote_enable=1 ● xdebug.remote_host= IDE host ● xdebug.remote_port="9000" ● xdebug.profiler_enable=1 ● xdebug.profiler_output_dir="/tmp" ● xdebug.idekey="drupal8"
  • 9. How do we check it? Web: echo phpinfo();
  • 10. Xdebug installation: How do we check it? Console (cli): php -v & php -i | grep remote
  • 11. IDE configuration ● Set Xdebug in PhpStorm ● Add a Php remote debug / Php Unit instance in PhpStorm ● Set session id (ide key)
  • 12. IDE configuration: Set XDebug ● Configure Php debug ● Configure server
  • 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
  • 18. Use case : Debug code (III)
  • 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