SlideShare a Scribd company logo
Debugging and Profiling
PHP Applications
Logan Lindquist
@llbbl
Debugging vs Profiling
Debugging
Bug fixing
Used during Development to minimize bugs
Profiling
Performance tuning
?????
What Is This Magic?!?
Xdebug is AWESOME
Pretty var_dumps
Enhanced

Stack Trace
Debugging
Profiling
OMGWTFBBQ Install it NOW
OSX:
Install homebrew
Follow instructions: https://github.com/Homebrew/homebrew-
php#installation
brew install php54-xdebug
Ubuntu:
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
php5-xdebug
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Windows: Install Vagrant then follow Ubuntu
Configure Xdebug for
Debugging
Turn on remote debugging:
xdebug.remote_enable=1
Configure what port, host, log file ... and more
xdebug.remote_port= 9000
xdebug.remote_log="/var/www/xdebug.log"
xdebug.remote_host="localhost"
Xdebug Profiling
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "/var/www/xdebug"
xdebug.profiler_output_name = xdebug.out.%t
Make sure you have the right PHP
Settings > PHP > Intrepreters
....you should see xdebug
Here is how to check symlinked or not
Tools > Deployment > Configuration
Gotchas
• Make sure profile directory exists and is writeable by
the web server
• Nothing works without xdebug.remote_enable=1
• Make sure port number matches in your ini and
phpstorm. Both default 9000
• SOOOOO many steps ... No shutup, stop being lazy
and just do it
How to trigger a debug session
• Javascript bookmarklets
• Chrome extension
• Within PhpStorm
• Magic
• Production crashes
Let's cover the first three
shall we?
Jetbrains Has The Goodies
http://www.jetbrains.com/phpstorm/marklets/
• Start Debugger:
• Goto page
• Hit Start Debugger
• Hit Stop Debugger when done debugging
• Debug this page:
• Goto page
• Hit Debug this page
Chrome Extension
Name: Xdebug Helper
https://chrome.google.com/webstore/detail/xdebug-
helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
PhpStorm
PhpStorm + Xdebug
Profiling with PhpStorm
Tools > Analyze Xdebug Profiler Snapshot
MCG https://itunes.apple.com/us/app/mcg/id799178412?mt=12
Profiling with MCG
XHProf
XHProf
XHProf
• Built by Facebook opensourced in 2009
• Xdebug not required
• Way more complicated to setup
• Documentation isn't great
• Requires you to add xhprof methods to your code
• Requires you to configure apache vhost for reporting
• Has callgraph charts (directed graphs) and a couple other nice features
Install isn't too bad with
homebrew or apt-get
In Review...
• Installed Xdebug
• Setup Xdebug with PhpStorm
• Configured Xdebug for profiling or debugging

More Related Content

Viewers also liked

Artificial Vision Using System No Blinds In The World
Artificial Vision Using System No Blinds In The WorldArtificial Vision Using System No Blinds In The World
Artificial Vision Using System No Blinds In The WorldR.PRABHU R.RAJENDRAN
 
Rice puller pdf home page ready to paste
Rice puller pdf home page ready to pasteRice puller pdf home page ready to paste
Rice puller pdf home page ready to pasteRice Puller
 
RICE PULLER NAHI HOTA HE 09425636422 + 09981011455 CLICK HERE FOR DETAIL ...
RICE PULLER NAHI HOTA HE 09425636422 + 09981011455 CLICK HERE FOR DETAIL     ...RICE PULLER NAHI HOTA HE 09425636422 + 09981011455 CLICK HERE FOR DETAIL     ...
RICE PULLER NAHI HOTA HE 09425636422 + 09981011455 CLICK HERE FOR DETAIL ...Rice Puller
 
Iridium.Ppt [Recovered]
Iridium.Ppt [Recovered]Iridium.Ppt [Recovered]
Iridium.Ppt [Recovered]hem
 
Basic overview of an artificial eye
Basic overview of an artificial eyeBasic overview of an artificial eye
Basic overview of an artificial eyeTabish Ansar
 
Report of PILL CAMERA
Report of PILL CAMERAReport of PILL CAMERA
Report of PILL CAMERArazaemohammed
 
10 myths about psychology
10 myths about psychology10 myths about psychology
10 myths about psychologyTED Talks
 
I'm a smartphone addict
I'm a smartphone addictI'm a smartphone addict
I'm a smartphone addictLior Frenkel
 
12 Time Management Techniques
12 Time Management Techniques12 Time Management Techniques
12 Time Management TechniquesWeekdone.com
 
Hacking & its types
Hacking & its typesHacking & its types
Hacking & its typesSai Sakoji
 
Can We Assess Creativity?
Can We Assess Creativity?Can We Assess Creativity?
Can We Assess Creativity?John Spencer
 

Viewers also liked (16)

Iridium
IridiumIridium
Iridium
 
Artificial Vision Using System No Blinds In The World
Artificial Vision Using System No Blinds In The WorldArtificial Vision Using System No Blinds In The World
Artificial Vision Using System No Blinds In The World
 
Rice puller pdf home page ready to paste
Rice puller pdf home page ready to pasteRice puller pdf home page ready to paste
Rice puller pdf home page ready to paste
 
RICE PULLER NAHI HOTA HE 09425636422 + 09981011455 CLICK HERE FOR DETAIL ...
RICE PULLER NAHI HOTA HE 09425636422 + 09981011455 CLICK HERE FOR DETAIL     ...RICE PULLER NAHI HOTA HE 09425636422 + 09981011455 CLICK HERE FOR DETAIL     ...
RICE PULLER NAHI HOTA HE 09425636422 + 09981011455 CLICK HERE FOR DETAIL ...
 
Iridium.Ppt [Recovered]
Iridium.Ppt [Recovered]Iridium.Ppt [Recovered]
Iridium.Ppt [Recovered]
 
Basic overview of an artificial eye
Basic overview of an artificial eyeBasic overview of an artificial eye
Basic overview of an artificial eye
 
Artificial eye
Artificial eyeArtificial eye
Artificial eye
 
Pill camera ppt
Pill camera pptPill camera ppt
Pill camera ppt
 
artificial eye
artificial eyeartificial eye
artificial eye
 
Report of PILL CAMERA
Report of PILL CAMERAReport of PILL CAMERA
Report of PILL CAMERA
 
10 myths about psychology
10 myths about psychology10 myths about psychology
10 myths about psychology
 
I'm a smartphone addict
I'm a smartphone addictI'm a smartphone addict
I'm a smartphone addict
 
Iridium satellite system
Iridium satellite systemIridium satellite system
Iridium satellite system
 
12 Time Management Techniques
12 Time Management Techniques12 Time Management Techniques
12 Time Management Techniques
 
Hacking & its types
Hacking & its typesHacking & its types
Hacking & its types
 
Can We Assess Creativity?
Can We Assess Creativity?Can We Assess Creativity?
Can We Assess Creativity?
 

Similar to Debugging and Profiling PHP Applications

Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Bastian Feder
 
Debugging Drupal with Xdebug
Debugging Drupal with XdebugDebugging Drupal with Xdebug
Debugging Drupal with XdebugFrank Carey
 
Setting advanced PHP development environment
Setting advanced PHP development environmentSetting advanced PHP development environment
Setting advanced PHP development environmentKapil Sharma
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneDavid Glick
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer ToolboxPablo Godel
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 
DDD (Debugger Driven Development)
DDD (Debugger Driven Development)DDD (Debugger Driven Development)
DDD (Debugger Driven Development)Carlos Granados
 
Improving WordPress Performance: Xdebug and PHP profiling
Improving WordPress Performance: Xdebug and PHP profilingImproving WordPress Performance: Xdebug and PHP profiling
Improving WordPress Performance: Xdebug and PHP profilingSeravo
 
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Francisco José Seva Mora
 
Introduction to Xdebug
Introduction to XdebugIntroduction to Xdebug
Introduction to XdebugAbid Malik
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudSalesforce Developers
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confooCombell NV
 
Fluentd and PHP
Fluentd and PHPFluentd and PHP
Fluentd and PHPchobi e
 
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
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Combell NV
 
Madison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small TeamsMadison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small TeamsJoe Ferguson
 

Similar to Debugging and Profiling PHP Applications (20)

Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
 
Debugging Drupal with Xdebug
Debugging Drupal with XdebugDebugging Drupal with Xdebug
Debugging Drupal with Xdebug
 
Setting advanced PHP development environment
Setting advanced PHP development environmentSetting advanced PHP development environment
Setting advanced PHP development environment
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
DDD (Debugger Driven Development)
DDD (Debugger Driven Development)DDD (Debugger Driven Development)
DDD (Debugger Driven Development)
 
Improving WordPress Performance: Xdebug and PHP profiling
Improving WordPress Performance: Xdebug and PHP profilingImproving WordPress Performance: Xdebug and PHP profiling
Improving WordPress Performance: Xdebug and PHP profiling
 
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
 
Introduction to Xdebug
Introduction to XdebugIntroduction to Xdebug
Introduction to Xdebug
 
Xdebug from a to x
Xdebug from a to xXdebug from a to x
Xdebug from a to x
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the Cloud
 
Xdebug
XdebugXdebug
Xdebug
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confoo
 
Fluentd and PHP
Fluentd and PHPFluentd and PHP
Fluentd and PHP
 
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)
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 
Madison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small TeamsMadison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small Teams
 

Recently uploaded

Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
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)Julian Hyde
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
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 Minutesconfluent
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
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 HalderCzechDreamin
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
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 KomCzechDreamin
 

Recently uploaded (20)

Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
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)
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
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
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
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
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
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
 

Debugging and Profiling PHP Applications

  • 1. Debugging and Profiling PHP Applications Logan Lindquist @llbbl
  • 2. Debugging vs Profiling Debugging Bug fixing Used during Development to minimize bugs Profiling Performance tuning
  • 4. What Is This Magic?!?
  • 5. Xdebug is AWESOME Pretty var_dumps Enhanced
 Stack Trace Debugging Profiling
  • 6. OMGWTFBBQ Install it NOW OSX: Install homebrew Follow instructions: https://github.com/Homebrew/homebrew- php#installation brew install php54-xdebug Ubuntu: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-xdebug ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" Windows: Install Vagrant then follow Ubuntu
  • 7. Configure Xdebug for Debugging Turn on remote debugging: xdebug.remote_enable=1 Configure what port, host, log file ... and more xdebug.remote_port= 9000 xdebug.remote_log="/var/www/xdebug.log" xdebug.remote_host="localhost"
  • 8. Xdebug Profiling xdebug.profiler_enable = 1 xdebug.profiler_enable_trigger = 1 xdebug.profiler_output_dir = "/var/www/xdebug" xdebug.profiler_output_name = xdebug.out.%t
  • 9. Make sure you have the right PHP Settings > PHP > Intrepreters ....you should see xdebug
  • 10. Here is how to check symlinked or not Tools > Deployment > Configuration
  • 11. Gotchas • Make sure profile directory exists and is writeable by the web server • Nothing works without xdebug.remote_enable=1 • Make sure port number matches in your ini and phpstorm. Both default 9000 • SOOOOO many steps ... No shutup, stop being lazy and just do it
  • 12. How to trigger a debug session • Javascript bookmarklets • Chrome extension • Within PhpStorm • Magic • Production crashes Let's cover the first three shall we?
  • 13. Jetbrains Has The Goodies http://www.jetbrains.com/phpstorm/marklets/ • Start Debugger: • Goto page • Hit Start Debugger • Hit Stop Debugger when done debugging • Debug this page: • Goto page • Hit Debug this page
  • 14. Chrome Extension Name: Xdebug Helper https://chrome.google.com/webstore/detail/xdebug- helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
  • 17. Profiling with PhpStorm Tools > Analyze Xdebug Profiler Snapshot
  • 22. XHProf • Built by Facebook opensourced in 2009 • Xdebug not required • Way more complicated to setup • Documentation isn't great • Requires you to add xhprof methods to your code • Requires you to configure apache vhost for reporting • Has callgraph charts (directed graphs) and a couple other nice features Install isn't too bad with homebrew or apt-get
  • 23. In Review... • Installed Xdebug • Setup Xdebug with PhpStorm • Configured Xdebug for profiling or debugging