SlideShare a Scribd company logo
1 of 13
Debugging PHP with Xdebug
Be Professional debugger with xdebug
Omid Khosrojerdi
omidkh68@gmail.com 1
Debugging PHP with XDebug
Omid Khosrojerdi
omidkh68@gmail.com
1. Why Debugging ?
2. Debug tools
3. XDebug
• What is XDebug ?
• XDebug Enable [php.ini]
• How to Install XDebug
• How to use XDebug
• XDebug remote connect
• XDebug with phpStorm
• XDebug browser extension
• XDebug in IDEs
2
Debugging PHP with XDebug - Debug tools
Omid Khosrojerdi
omidkh68@gmail.com
• Var_dump()
• Print_r()
• echo
• Xdump
• Kint
• Pinba
• XDebug
• IDEs
• ....
3
Debugging PHP with XDebug – What is XDebug ?
Omid Khosrojerdi
omidkh68@gmail.com
What is XDebug ?
With dbgp protocol
4
Debugging PHP with XDebug - XDebug features
Omid Khosrojerdi
omidkh68@gmail.com
By Function :
xdebug_start_trace();
xdebug_stop_trace();
Automatically (php.ini) :
xdebug.auto_trace = “1”
Note : Can’t Using ini_set();
5
Debugging PHP with XDebug – XDebug Enable [php.ini]
Omid Khosrojerdi
omidkh68@gmail.com
• xdebug.default_enable=1
• xdebug.coverage_enable=1
• xdebug.profiler_enable = 1
• xdebug.remote_handler = dbgp
• Linux – Mac osx : xdebug.profiler_output_dir = "/tmp“
• Windows : xdebug.profiler_output_dir = “C:wamptmp“
• xdebug.remote_enable=1
• xdebug.remote_host=localhost
• xdebug.remote_port=9000
• xdebug.remote_autostart=1
• xdebug.show_local_vars=1
• xdebug.show_local_vars=On
• xdebug.collect_params=4
• xdebug.show_exception_trace=On
6
Debugging PHP with XDebug - How to Install XDebug ?
Omid Khosrojerdi
omidkh68@gmail.com
Installing with PEAR/PECL for unix/linux:
# pecl install xdebug
Installing From Source :
git clone git://github.com/xdebug/xdebug.git
Wamp OR Xampp OR Mamp Server :
Installed Built-in
7
Debugging PHP with XDebug - How to use XDebug ?
Omid Khosrojerdi
omidkh68@gmail.com
Example: return execute duration time
<?php
echo xdebug_time_index(), "n";
for ($i = 0; $i < 250000; $i++)
{
// do nothing
}
echo xdebug_time_index(), "n";
?>
Returns:
0.00038003921508789
0.76580691337585
8
NOTE :
ini_set('display_errors', ‘On');
Debugging PHP with XDebug – XDebug remote Connect
Omid Khosrojerdi
omidkh68@gmail.com 9
Debugging PHP with XDebug - XDebug browser extension
Omid Khosrojerdi
omidkh68@gmail.com
Chrome Extension
FirefoxAddons
10
https://addons.mozilla.org/en-US/firefox/addon/easy-xdebug/
https://chrome.google.com/webstore/detail/xdebug-
helper/eadndfjplgieldjbigjakmdgkmoaaaoc
Debugging PHP with XDebug - XDebug in IDEs
Omid Khosrojerdi
omidkh68@gmail.com
phpStorm :
https://www.jetbrains.com/phpstorm/webhelp/configuring-xdebug.html
Zend studio :
http://files.zend.com/help/Zend-Studio/content/installing_xdebug.htm
NetBeans :
https://netbeans.org/kb/docs/php/debugging.html
11
Debugging PHP with XDebug - References
Omid Khosrojerdi
omidkh68@gmail.com
http://xdebug.org/
http://coding.smashingmagazine.com/2009/01/20/50-extremely-useful-php-tools/
https://www.jetbrains.com/phpstorm/webhelp/configuring-xdebug.html
http://files.zend.com/help/Zend-Studio/content/installing_xdebug.htm
http://devzone.zend.com/1120/introducing-xdebug/
12
Debugging PHP with XDebug - Question
Omid Khosrojerdi
omidkh68@gmail.com
Question?
13

More Related Content

What's hot

Let's creating your own PHP (tejimaya version)
Let's creating your own PHP (tejimaya version)Let's creating your own PHP (tejimaya version)
Let's creating your own PHP (tejimaya version)
Kousuke Ebihara
 

What's hot (20)

Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...
 
BDD in PHP - Behat
BDD in PHP - BehatBDD in PHP - Behat
BDD in PHP - Behat
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.
 
Getting Started With Xdebug
Getting Started With XdebugGetting Started With Xdebug
Getting Started With Xdebug
 
Php[tek] 2016 - BDD with Behat for Beginners
Php[tek] 2016 - BDD with Behat for BeginnersPhp[tek] 2016 - BDD with Behat for Beginners
Php[tek] 2016 - BDD with Behat for Beginners
 
Back to the future: Isomorphic javascript applications
Back to the future:  Isomorphic javascript applicationsBack to the future:  Isomorphic javascript applications
Back to the future: Isomorphic javascript applications
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of docker
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Node js (runtime environment + js library) platform
Node js (runtime environment + js library) platformNode js (runtime environment + js library) platform
Node js (runtime environment + js library) platform
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
 
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...Write an API for Almost Anything: The Amazing Power and Flexibility of Django...
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...
 
Phalcon Framework: San Antonio Web Developers Group
Phalcon Framework: San Antonio Web Developers Group Phalcon Framework: San Antonio Web Developers Group
Phalcon Framework: San Antonio Web Developers Group
 
Managing a Local WordPress Community, WordCamp Europe 2016
Managing a Local WordPress Community, WordCamp Europe 2016Managing a Local WordPress Community, WordCamp Europe 2016
Managing a Local WordPress Community, WordCamp Europe 2016
 
Let's creating your own PHP (tejimaya version)
Let's creating your own PHP (tejimaya version)Let's creating your own PHP (tejimaya version)
Let's creating your own PHP (tejimaya version)
 
Modularity problems
Modularity  problemsModularity  problems
Modularity problems
 
Scaling php - Intercon php
Scaling php - Intercon phpScaling php - Intercon php
Scaling php - Intercon php
 
Debugging PHP With Xdebug
Debugging PHP With XdebugDebugging PHP With Xdebug
Debugging PHP With Xdebug
 
Web development with Python
Web development with PythonWeb development with Python
Web development with Python
 
Hello npm
Hello npmHello npm
Hello npm
 

Similar to XDebug For php debugging

How to really obfuscate your pdf malware
How to really obfuscate   your pdf malwareHow to really obfuscate   your pdf malware
How to really obfuscate your pdf malware
zynamics GmbH
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
zynamics GmbH
 
Php code profiling_using_x_debug
Php code profiling_using_x_debugPhp code profiling_using_x_debug
Php code profiling_using_x_debug
Gennady Feldman
 
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
Frédéric Harper
 

Similar to XDebug For php debugging (20)

PHP: Debugger, Profiler and more
PHP: Debugger, Profiler and morePHP: Debugger, Profiler and more
PHP: Debugger, Profiler and more
 
7 Top PHP Development Tools For PHP Coding
7 Top PHP Development Tools For PHP Coding7 Top PHP Development Tools For PHP Coding
7 Top PHP Development Tools For PHP Coding
 
How to really obfuscate your pdf malware
How to really obfuscate   your pdf malwareHow to really obfuscate   your pdf malware
How to really obfuscate your pdf malware
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
 
Php code profiling_using_x_debug
Php code profiling_using_x_debugPhp code profiling_using_x_debug
Php code profiling_using_x_debug
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 Plugin
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
 
Learn to build a CodeIgniter Login and Registration with source code.pdf
Learn to build a CodeIgniter Login and Registration with source code.pdfLearn to build a CodeIgniter Login and Registration with source code.pdf
Learn to build a CodeIgniter Login and Registration with source code.pdf
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Xdebug
XdebugXdebug
Xdebug
 
Php Code Profiling Using X Debug
Php Code Profiling Using X DebugPhp Code Profiling Using X Debug
Php Code Profiling Using X Debug
 
Coscup
CoscupCoscup
Coscup
 
TDD BDD PHP - Sviluppo guidato dai test in PHP con phpspec
TDD BDD PHP - Sviluppo guidato dai test in PHP con phpspecTDD BDD PHP - Sviluppo guidato dai test in PHP con phpspec
TDD BDD PHP - Sviluppo guidato dai test in PHP con phpspec
 
It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspec
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matter
 
Programming tools for developers
Programming tools for developersProgramming tools for developers
Programming tools for developers
 
Tool up your lamp stack
Tool up your lamp stackTool up your lamp stack
Tool up your lamp stack
 
Tool Up Your LAMP Stack
Tool Up Your LAMP StackTool Up Your LAMP Stack
Tool Up Your LAMP Stack
 
Get Codeigniter Developement Services From Us
 Get Codeigniter Developement Services From Us Get Codeigniter Developement Services From Us
Get Codeigniter Developement Services From Us
 
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
DevTeach Ottawa - Webmatrix, see what the matrix can do for you!!
 

Recently uploaded

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Recently uploaded (20)

Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 

XDebug For php debugging

  • 1. Debugging PHP with Xdebug Be Professional debugger with xdebug Omid Khosrojerdi omidkh68@gmail.com 1
  • 2. Debugging PHP with XDebug Omid Khosrojerdi omidkh68@gmail.com 1. Why Debugging ? 2. Debug tools 3. XDebug • What is XDebug ? • XDebug Enable [php.ini] • How to Install XDebug • How to use XDebug • XDebug remote connect • XDebug with phpStorm • XDebug browser extension • XDebug in IDEs 2
  • 3. Debugging PHP with XDebug - Debug tools Omid Khosrojerdi omidkh68@gmail.com • Var_dump() • Print_r() • echo • Xdump • Kint • Pinba • XDebug • IDEs • .... 3
  • 4. Debugging PHP with XDebug – What is XDebug ? Omid Khosrojerdi omidkh68@gmail.com What is XDebug ? With dbgp protocol 4
  • 5. Debugging PHP with XDebug - XDebug features Omid Khosrojerdi omidkh68@gmail.com By Function : xdebug_start_trace(); xdebug_stop_trace(); Automatically (php.ini) : xdebug.auto_trace = “1” Note : Can’t Using ini_set(); 5
  • 6. Debugging PHP with XDebug – XDebug Enable [php.ini] Omid Khosrojerdi omidkh68@gmail.com • xdebug.default_enable=1 • xdebug.coverage_enable=1 • xdebug.profiler_enable = 1 • xdebug.remote_handler = dbgp • Linux – Mac osx : xdebug.profiler_output_dir = "/tmp“ • Windows : xdebug.profiler_output_dir = “C:wamptmp“ • xdebug.remote_enable=1 • xdebug.remote_host=localhost • xdebug.remote_port=9000 • xdebug.remote_autostart=1 • xdebug.show_local_vars=1 • xdebug.show_local_vars=On • xdebug.collect_params=4 • xdebug.show_exception_trace=On 6
  • 7. Debugging PHP with XDebug - How to Install XDebug ? Omid Khosrojerdi omidkh68@gmail.com Installing with PEAR/PECL for unix/linux: # pecl install xdebug Installing From Source : git clone git://github.com/xdebug/xdebug.git Wamp OR Xampp OR Mamp Server : Installed Built-in 7
  • 8. Debugging PHP with XDebug - How to use XDebug ? Omid Khosrojerdi omidkh68@gmail.com Example: return execute duration time <?php echo xdebug_time_index(), "n"; for ($i = 0; $i < 250000; $i++) { // do nothing } echo xdebug_time_index(), "n"; ?> Returns: 0.00038003921508789 0.76580691337585 8 NOTE : ini_set('display_errors', ‘On');
  • 9. Debugging PHP with XDebug – XDebug remote Connect Omid Khosrojerdi omidkh68@gmail.com 9
  • 10. Debugging PHP with XDebug - XDebug browser extension Omid Khosrojerdi omidkh68@gmail.com Chrome Extension FirefoxAddons 10 https://addons.mozilla.org/en-US/firefox/addon/easy-xdebug/ https://chrome.google.com/webstore/detail/xdebug- helper/eadndfjplgieldjbigjakmdgkmoaaaoc
  • 11. Debugging PHP with XDebug - XDebug in IDEs Omid Khosrojerdi omidkh68@gmail.com phpStorm : https://www.jetbrains.com/phpstorm/webhelp/configuring-xdebug.html Zend studio : http://files.zend.com/help/Zend-Studio/content/installing_xdebug.htm NetBeans : https://netbeans.org/kb/docs/php/debugging.html 11
  • 12. Debugging PHP with XDebug - References Omid Khosrojerdi omidkh68@gmail.com http://xdebug.org/ http://coding.smashingmagazine.com/2009/01/20/50-extremely-useful-php-tools/ https://www.jetbrains.com/phpstorm/webhelp/configuring-xdebug.html http://files.zend.com/help/Zend-Studio/content/installing_xdebug.htm http://devzone.zend.com/1120/introducing-xdebug/ 12
  • 13. Debugging PHP with XDebug - Question Omid Khosrojerdi omidkh68@gmail.com Question? 13