SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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!!
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

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