SlideShare une entreprise Scribd logo
1  sur  81
Télécharger pour lire hors ligne
D E B U G G I N G P H P W I T H
X D E B U G
M A R K N I E B E R G A L L
https://joind.in/talk/14128
A B O U T M A R K N I E B E R G A L L
• PHP since 2005
• Masters degree in MIS
• Senior Software Engineer
• Team Lead
• Drug screening project
• President of Utah PHP User Group (UPHPU)
• SSCP, CSSLP Certified and SME for (ISC)2
• PHP, databases, JavaScript
• Drones, fishing, skiing, father, husband
A B O U T M A R K N I E B E R G A L L
D E B U G G I N G P H P W I T H X D E B U G
UPHPU
• Third Thursday of each month at 7pm
• Venue is Vivint in Lehi (3401 Ashton Blvd)
• Variety of PHP related topics
• Mostly local speakers, occasional traveling speaker
• Networking with other developers, companies
• Professional development
• uphpu.org
D E B U G G I N G P H P W I T H
D E B U G
D E B U G G I N G P H P W I T H X D E B U G
Overview
• What is Xdebug
• Why use Xdebug
• Setting up Xdebug
• Using Xdebug
W H AT I S X D E B U G
W H AT I S X D E B U G
W H AT I S X D E B U G
Xdebug
• Available since 2002
• Developed initially by Derick Rethans
• PHP extension
• Written in C
• Open source
• Used for debugging and profiling
• Uses DeBugGer Protocol (DBGp) for communication
W H Y U S E X D E B U G
W H Y U S E X D E B U G
Debugging without Xdebug
W H Y U S E X D E B U G
Debugging without Xdebug
• echo $something;
• var_dump($other);
• print_r($data);
• error_log(__FILE__ . ‘ line ‘ . __LINE__);
W H Y U S E X D E B U G
Debugging without Xdebug
• Add outputs
• Load page
• Look for output
• Change some code
• Add more outputs
• Repeat
• Cleanup outputs without missing any
• Load page
W H Y U S E X D E B U G
Debugging with Xdebug
W H Y U S E X D E B U G
Debugging with Xdebug
• Add breakpoint(s)
• Load page
• Step into the code
W H Y U S E X D E B U G
Debugging with Xdebug
• Live values
• Follow actual code path
• Full stacktrace
W H Y U S E X D E B U G
Debugging with Xdebug
• Supported by most IDEs
• Faster development time
• Better understanding of what code is actually doing
• Does not require code changes to interrogate values
S E T T I N G U P X D E B U G
S E T T I N G U P X D E B U G
Fire up you development environment
S E T T I N G U P X D E B U G
Documentation from JetBrain for PhpStorm
https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web
+Application+Debugging+with+Xdebug+and+PhpStorm
1. Install Xdebug
2. Prepare PhpStorm
3. Set a breakpoint in the source code
4. Activate debugger on server
5. Start a debug session in browser
6. Reload the current page
7. Set initial path mappings
S E T T I N G U P X D E B U G
1. Install Xdebug
S E T T I N G U P X D E B U G
1. Install Xdebug
• https://xdebug.org/docs/install
S E T T I N G U P X D E B U G
1. Install Xdebug
• Download (if applicable)
• Install or compile
• Configure PHP
• Restart webserver
S E T T I N G U P X D E B U G
1. Install Xdebug
• Windows:
- Xdebug website has a wizard, dll downloads
• Mac:
- sudo pecl install xdebug
- brew install php70-xdebug
• Linux:
- wget http://xdebug.org/files/xdebug-2.4.0.tgz
- sudo pecl install xdebug
S E T T I N G U P X D E B U G
1. Install Xdebug
• Windows: download dll
- Xdebug website has a wizard, downloads
- Paste php -i or phpinfo() (ex: C:phpphp -i > C:
phpphpinfo.txt or <?php phpinfo();)
- dll download link provided
- Add a line to your php.ini file
- Restart webserver
S E T T I N G U P X D E B U G
1. Install Xdebug
• apt-get install php5-xdebug
• wget http://xdebug.org/files/xdebug-2.4.0.tgz

tar -xzvf xdebug-2.4.0.tgz

cd xdebug-2.4.0

phpize

./configure --enable-xdebug

make

make install
S E T T I N G U P X D E B U G
1. Install Xdebug
• yum install php-devel

yum install php-pear

pecl install xdebug
• dnf install php-devel

dnf install php-pear

pecl install xdebug
S E T T I N G U P X D E B U G
1. Install Xdebug
• Update php.ini by adding lines:



zend_extension = php_xdebug-2.4.0-5.5-vc11.dll



[xdebug]

xdebug.remote_enable = 1

xdebug.remote_port = 9000

xdebug.remote_host = localhost

xdebug.idekey = PHPSTORM

S E T T I N G U P X D E B U G
1. Install Xdebug
• Update php.ini by adding lines:



zend_extension = /usr/lib64/php/modules/xdebug.so



[xdebug]

xdebug.remote_enable = 1

xdebug.remote_port = 9000

xdebug.remote_host = localhost

xdebug.idekey = PHPSTORM

S E T T I N G U P X D E B U G
1. Install Xdebug
• Restart webserver
- Windows:

Services

Apache Monitor
- Linux:

sudo apachectl restart

sudo service nginx restart
S E T T I N G U P X D E B U G
1. Install Xdebug
• Verify via phpinfo
- <?php phpinfo();
- php -i | grep xdebug
S E T T I N G U P X D E B U G
1. Install Xdebug
• Verify via phpinfo
S E T T I N G U P X D E B U G
2. Prepare PhpStorm
S E T T I N G U P X D E B U G
2. Prepare PhpStorm
• Start Listening for PHP Debug Connections
S E T T I N G U P X D E B U G
2. Prepare PhpStorm
S E T T I N G U P X D E B U G
2. Prepare PhpStorm
S E T T I N G U P X D E B U G
2. Prepare PhpStorm
• Setup debug settings
S E T T I N G U P X D E B U G
2. Prepare PhpStorm
• Setup project path mapping
S E T T I N G U P X D E B U G
2. Prepare PhpStorm
S E T T I N G U P X D E B U G
3. Set a breakpoint in the source code
S E T T I N G U P X D E B U G
3. Set a breakpoint in the source code
• Line you know will be hit
• Or break on first line
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
• Browser plugin, add-on
- The easiest Xdebug (Firefox)
- Xdebug Helper (Chrome)
- Xdebug Toggler (Safari)
- Xdebug launcher (Opera)
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
• URL
- GET: &XDEBUG_SESSION_START=PHPSTORM
- POST: XDEBUG_SESSION_START=PHPSTORM
• Headers
- Name: Cookie
- Value: XDEBUG_SESSION=PHPSTORM
• Bookmarklet
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
4. Activate debugger on server
S E T T I N G U P X D E B U G
5. Start a debug session in browser
S E T T I N G U P X D E B U G
5. Start a debug session in browser
• Click the debug button in toolbar
• Add GET, POST, or COOKIE
S E T T I N G U P X D E B U G
6. Reload the current page
S E T T I N G U P X D E B U G
6. Reload the current page
S E T T I N G U P X D E B U G
7. Set initial path mappings
S E T T I N G U P X D E B U G
7. Set initial path mappings
U S I N G X D E B U G
U S I N G X D E B U G
U S I N G X D E B U G
• Breakpoints
• Stepping through code
• Watches
• Console
U S I N G X D E B U G
U S I N G X D E B U G
Breakpoints
• Pause code execution at specific line
• Allowed multiple breakpoints
• Conditional breakpoints
U S I N G X D E B U G
Breakpoints
• Place strategically
• Not too early
• Not too late
• Not too many
• Remember time limit, increase if needed
• Use conditional breakpoints in loops
U S I N G X D E B U G
Breakpoints
U S I N G X D E B U G
Breakpoints
U S I N G X D E B U G
Stepping through code
U S I N G X D E B U G
Stepping through code
• Resume Program (Play)
• Stop
• View Breakpoints
• Disable All Breakpoints
U S I N G X D E B U G
Stepping through code
• Step Over
• Step Into
• Force Step Into
• Step Out
• Run to Cursor
U S I N G X D E B U G
Stepping through code
• Evaluate Expression
• Show value addresses
• Hide empty superglobal variables (on by default)
• Add method to skip list
U S I N G X D E B U G
Watches
U S I N G X D E B U G
Watches
• Live updates
• Values
• Expressions
U S I N G X D E B U G
Console
U S I N G X D E B U G
Console
• Output from debugging expressions
• Enter expressions to be evaluated
S U M M A RY
S U M M A RY
• More efficient way to debug
• Visibility into code
• Ability to change code on the fly
• Watch values change line by line
• Better understanding of code path
Q U E S T I O N S ?
https://joind.in/talk/14128
S O U R C E S
• JetBrains documentation https://confluence.jetbrains.com/display/PhpStorm/Zero-
configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
• Xdebug documentation https://xdebug.org/docs/install
• David Stockton, php[architect], January 2015, https://www.phparch.com/wp-
content/uploads/2015/01/levelup-xdebug-phparchitect-jan2015.pdf

Contenu connexe

Tendances

NGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX, Inc.
 
Introduction to NGINX web server
Introduction to NGINX web serverIntroduction to NGINX web server
Introduction to NGINX web serverMd Waresul Islam
 
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)Ji-Woong Choi
 
Load Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINXLoad Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINXNGINX, Inc.
 
Node js Modules and Event Emitters
Node js Modules and Event EmittersNode js Modules and Event Emitters
Node js Modules and Event EmittersTheCreativedev Blog
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleCoreStack
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack IntroductionAnjali Chawla
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleOmid Vahdaty
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - ExplainedSmita Prasad
 
Postgresql 12 streaming replication hol
Postgresql 12 streaming replication holPostgresql 12 streaming replication hol
Postgresql 12 streaming replication holVijay Kumar N
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django ArchitectureRami Sayar
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90minsLarry Cai
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 

Tendances (20)

Vagrant
VagrantVagrant
Vagrant
 
NGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX: High Performance Load Balancing
NGINX: High Performance Load Balancing
 
Introduction to NGINX web server
Introduction to NGINX web serverIntroduction to NGINX web server
Introduction to NGINX web server
 
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Load Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINXLoad Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINX
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
Node js Modules and Event Emitters
Node js Modules and Event EmittersNode js Modules and Event Emitters
Node js Modules and Event Emitters
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack Introduction
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
PostgreSQL Replication Tutorial
PostgreSQL Replication TutorialPostgreSQL Replication Tutorial
PostgreSQL Replication Tutorial
 
Postgresql 12 streaming replication hol
Postgresql 12 streaming replication holPostgresql 12 streaming replication hol
Postgresql 12 streaming replication hol
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django Architecture
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 

En vedette

Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
TDC 2011 - E no sétimo dia ele escreveu testes
TDC 2011 - E no sétimo dia ele escreveu testesTDC 2011 - E no sétimo dia ele escreveu testes
TDC 2011 - E no sétimo dia ele escreveu testesRafael Dohms
 
Intro to Debugging PHP with Xdebug
Intro to Debugging PHP with XdebugIntro to Debugging PHP with Xdebug
Intro to Debugging PHP with XdebugJohn Kary
 
Essential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksEssential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksKaloyan Raev
 
Debugging in PHP
Debugging in PHPDebugging in PHP
Debugging in PHPMicah Wood
 
Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Patrick Allaert
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPatrick Allaert
 
Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Colin O'Dell
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through ExamplesCiaranMcNulty
 

En vedette (12)

Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
TDC 2011 - E no sétimo dia ele escreveu testes
TDC 2011 - E no sétimo dia ele escreveu testesTDC 2011 - E no sétimo dia ele escreveu testes
TDC 2011 - E no sétimo dia ele escreveu testes
 
Intro to Debugging PHP with Xdebug
Intro to Debugging PHP with XdebugIntro to Debugging PHP with Xdebug
Intro to Debugging PHP with Xdebug
 
Essential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksEssential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricks
 
Xdebug (ukr)
Xdebug (ukr)Xdebug (ukr)
Xdebug (ukr)
 
Debugging in PHP
Debugging in PHPDebugging in PHP
Debugging in PHP
 
Cryptography With PHP
Cryptography With PHPCryptography With PHP
Cryptography With PHP
 
Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
 
Debugging
DebuggingDebugging
Debugging
 
Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through Examples
 

Similaire à Debugging PHP With Xdebug

Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Mark Niebergall
 
Chef - Administration for programmers
Chef - Administration for programmersChef - Administration for programmers
Chef - Administration for programmersmrsabo
 
Docker for Development
Docker for DevelopmentDocker for Development
Docker for Developmentallingeek
 
Hogy jussunk ki lezárt hálózatokból?
Hogy jussunk ki lezárt hálózatokból?Hogy jussunk ki lezárt hálózatokból?
Hogy jussunk ki lezárt hálózatokból?hackersuli
 
Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Barry Kooij
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Software, Inc.
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Mark Niebergall
 
ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2Jürgen Gutsch
 
200,000 Lines Later: Our Journey to Manageable Puppet Code
200,000 Lines Later: Our Journey to Manageable Puppet Code200,000 Lines Later: Our Journey to Manageable Puppet Code
200,000 Lines Later: Our Journey to Manageable Puppet CodeDavid Danzilio
 
Intro to WordPress Plugins
Intro to WordPress PluginsIntro to WordPress Plugins
Intro to WordPress Pluginszamoose
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS DebuggingRami Sayar
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Chef
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingFITC
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
 
We Make Debugging Sucks Less
We Make Debugging Sucks LessWe Make Debugging Sucks Less
We Make Debugging Sucks LessAlon Fliess
 
Autotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP BasicsAutotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP BasicsArtur Babyuk
 
Production ready word press
Production ready word pressProduction ready word press
Production ready word pressEdmund Turbin
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Michael Lihs
 

Similaire à Debugging PHP With Xdebug (20)

Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018
 
Chef - Administration for programmers
Chef - Administration for programmersChef - Administration for programmers
Chef - Administration for programmers
 
Docker for Development
Docker for DevelopmentDocker for Development
Docker for Development
 
Hogy jussunk ki lezárt hálózatokból?
Hogy jussunk ki lezárt hálózatokból?Hogy jussunk ki lezárt hálózatokból?
Hogy jussunk ki lezárt hálózatokból?
 
Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014Plugin Development @ WordCamp Norway 2014
Plugin Development @ WordCamp Norway 2014
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
 
ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2
 
200,000 Lines Later: Our Journey to Manageable Puppet Code
200,000 Lines Later: Our Journey to Manageable Puppet Code200,000 Lines Later: Our Journey to Manageable Puppet Code
200,000 Lines Later: Our Journey to Manageable Puppet Code
 
Intro to WordPress Plugins
Intro to WordPress PluginsIntro to WordPress Plugins
Intro to WordPress Plugins
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS Debugging
 
Beyond Puppet
Beyond PuppetBeyond Puppet
Beyond Puppet
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript Debugging
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
 
We Make Debugging Sucks Less
We Make Debugging Sucks LessWe Make Debugging Sucks Less
We Make Debugging Sucks Less
 
Autotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP BasicsAutotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP Basics
 
Production ready word press
Production ready word pressProduction ready word press
Production ready word press
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 

Plus de Mark Niebergall

Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023Mark Niebergall
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Mark Niebergall
 
Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023Mark Niebergall
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Mark Niebergall
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentMark Niebergall
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatMark Niebergall
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatMark Niebergall
 
Relational Database Design Bootcamp
Relational Database Design BootcampRelational Database Design Bootcamp
Relational Database Design BootcampMark Niebergall
 
Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Mark Niebergall
 
Defensive Coding Crash Course Tutorial
Defensive Coding Crash Course TutorialDefensive Coding Crash Course Tutorial
Defensive Coding Crash Course TutorialMark Niebergall
 
Inheritance: Vertical or Horizontal
Inheritance: Vertical or HorizontalInheritance: Vertical or Horizontal
Inheritance: Vertical or HorizontalMark Niebergall
 
Cybersecurity State of the Union
Cybersecurity State of the UnionCybersecurity State of the Union
Cybersecurity State of the UnionMark Niebergall
 
Cryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 WorkshopCryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 WorkshopMark Niebergall
 
Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017Mark Niebergall
 
Leveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsLeveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsMark Niebergall
 
Defensive Coding Crash Course
Defensive Coding Crash CourseDefensive Coding Crash Course
Defensive Coding Crash CourseMark Niebergall
 

Plus de Mark Niebergall (20)

Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
 
Developing SOLID Code
Developing SOLID CodeDeveloping SOLID Code
Developing SOLID Code
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to Deployment
 
Stacking Up Middleware
Stacking Up MiddlewareStacking Up Middleware
Stacking Up Middleware
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and Behat
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and Behat
 
Hacking with PHP
Hacking with PHPHacking with PHP
Hacking with PHP
 
Relational Database Design Bootcamp
Relational Database Design BootcampRelational Database Design Bootcamp
Relational Database Design Bootcamp
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
 
Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018
 
Defensive Coding Crash Course Tutorial
Defensive Coding Crash Course TutorialDefensive Coding Crash Course Tutorial
Defensive Coding Crash Course Tutorial
 
Inheritance: Vertical or Horizontal
Inheritance: Vertical or HorizontalInheritance: Vertical or Horizontal
Inheritance: Vertical or Horizontal
 
Cybersecurity State of the Union
Cybersecurity State of the UnionCybersecurity State of the Union
Cybersecurity State of the Union
 
Cryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 WorkshopCryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 Workshop
 
Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017
 
Leveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsLeveraging Composer in Existing Projects
Leveraging Composer in Existing Projects
 
Defensive Coding Crash Course
Defensive Coding Crash CourseDefensive Coding Crash Course
Defensive Coding Crash Course
 

Dernier

WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 

Dernier (20)

WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 

Debugging PHP With Xdebug

  • 1. D E B U G G I N G P H P W I T H X D E B U G M A R K N I E B E R G A L L https://joind.in/talk/14128
  • 2. A B O U T M A R K N I E B E R G A L L • PHP since 2005 • Masters degree in MIS • Senior Software Engineer • Team Lead • Drug screening project • President of Utah PHP User Group (UPHPU) • SSCP, CSSLP Certified and SME for (ISC)2 • PHP, databases, JavaScript • Drones, fishing, skiing, father, husband
  • 3. A B O U T M A R K N I E B E R G A L L
  • 4. D E B U G G I N G P H P W I T H X D E B U G UPHPU • Third Thursday of each month at 7pm • Venue is Vivint in Lehi (3401 Ashton Blvd) • Variety of PHP related topics • Mostly local speakers, occasional traveling speaker • Networking with other developers, companies • Professional development • uphpu.org
  • 5. D E B U G G I N G P H P W I T H D E B U G
  • 6. D E B U G G I N G P H P W I T H X D E B U G Overview • What is Xdebug • Why use Xdebug • Setting up Xdebug • Using Xdebug
  • 7. W H AT I S X D E B U G
  • 8. W H AT I S X D E B U G
  • 9. W H AT I S X D E B U G Xdebug • Available since 2002 • Developed initially by Derick Rethans • PHP extension • Written in C • Open source • Used for debugging and profiling • Uses DeBugGer Protocol (DBGp) for communication
  • 10. W H Y U S E X D E B U G
  • 11. W H Y U S E X D E B U G Debugging without Xdebug
  • 12. W H Y U S E X D E B U G Debugging without Xdebug • echo $something; • var_dump($other); • print_r($data); • error_log(__FILE__ . ‘ line ‘ . __LINE__);
  • 13. W H Y U S E X D E B U G Debugging without Xdebug • Add outputs • Load page • Look for output • Change some code • Add more outputs • Repeat • Cleanup outputs without missing any • Load page
  • 14. W H Y U S E X D E B U G Debugging with Xdebug
  • 15. W H Y U S E X D E B U G Debugging with Xdebug • Add breakpoint(s) • Load page • Step into the code
  • 16. W H Y U S E X D E B U G Debugging with Xdebug • Live values • Follow actual code path • Full stacktrace
  • 17. W H Y U S E X D E B U G Debugging with Xdebug • Supported by most IDEs • Faster development time • Better understanding of what code is actually doing • Does not require code changes to interrogate values
  • 18. S E T T I N G U P X D E B U G
  • 19. S E T T I N G U P X D E B U G Fire up you development environment
  • 20. S E T T I N G U P X D E B U G Documentation from JetBrain for PhpStorm https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web +Application+Debugging+with+Xdebug+and+PhpStorm 1. Install Xdebug 2. Prepare PhpStorm 3. Set a breakpoint in the source code 4. Activate debugger on server 5. Start a debug session in browser 6. Reload the current page 7. Set initial path mappings
  • 21. S E T T I N G U P X D E B U G 1. Install Xdebug
  • 22. S E T T I N G U P X D E B U G 1. Install Xdebug • https://xdebug.org/docs/install
  • 23. S E T T I N G U P X D E B U G 1. Install Xdebug • Download (if applicable) • Install or compile • Configure PHP • Restart webserver
  • 24. S E T T I N G U P X D E B U G 1. Install Xdebug • Windows: - Xdebug website has a wizard, dll downloads • Mac: - sudo pecl install xdebug - brew install php70-xdebug • Linux: - wget http://xdebug.org/files/xdebug-2.4.0.tgz - sudo pecl install xdebug
  • 25. S E T T I N G U P X D E B U G 1. Install Xdebug • Windows: download dll - Xdebug website has a wizard, downloads - Paste php -i or phpinfo() (ex: C:phpphp -i > C: phpphpinfo.txt or <?php phpinfo();) - dll download link provided - Add a line to your php.ini file - Restart webserver
  • 26. S E T T I N G U P X D E B U G 1. Install Xdebug • apt-get install php5-xdebug • wget http://xdebug.org/files/xdebug-2.4.0.tgz
 tar -xzvf xdebug-2.4.0.tgz
 cd xdebug-2.4.0
 phpize
 ./configure --enable-xdebug
 make
 make install
  • 27. S E T T I N G U P X D E B U G 1. Install Xdebug • yum install php-devel
 yum install php-pear
 pecl install xdebug • dnf install php-devel
 dnf install php-pear
 pecl install xdebug
  • 28. S E T T I N G U P X D E B U G 1. Install Xdebug • Update php.ini by adding lines:
 
 zend_extension = php_xdebug-2.4.0-5.5-vc11.dll
 
 [xdebug]
 xdebug.remote_enable = 1
 xdebug.remote_port = 9000
 xdebug.remote_host = localhost
 xdebug.idekey = PHPSTORM

  • 29. S E T T I N G U P X D E B U G 1. Install Xdebug • Update php.ini by adding lines:
 
 zend_extension = /usr/lib64/php/modules/xdebug.so
 
 [xdebug]
 xdebug.remote_enable = 1
 xdebug.remote_port = 9000
 xdebug.remote_host = localhost
 xdebug.idekey = PHPSTORM

  • 30. S E T T I N G U P X D E B U G 1. Install Xdebug • Restart webserver - Windows:
 Services
 Apache Monitor - Linux:
 sudo apachectl restart
 sudo service nginx restart
  • 31. S E T T I N G U P X D E B U G 1. Install Xdebug • Verify via phpinfo - <?php phpinfo(); - php -i | grep xdebug
  • 32. S E T T I N G U P X D E B U G 1. Install Xdebug • Verify via phpinfo
  • 33. S E T T I N G U P X D E B U G 2. Prepare PhpStorm
  • 34. S E T T I N G U P X D E B U G 2. Prepare PhpStorm • Start Listening for PHP Debug Connections
  • 35. S E T T I N G U P X D E B U G 2. Prepare PhpStorm
  • 36. S E T T I N G U P X D E B U G 2. Prepare PhpStorm
  • 37. S E T T I N G U P X D E B U G 2. Prepare PhpStorm • Setup debug settings
  • 38.
  • 39. S E T T I N G U P X D E B U G 2. Prepare PhpStorm • Setup project path mapping
  • 40. S E T T I N G U P X D E B U G 2. Prepare PhpStorm
  • 41. S E T T I N G U P X D E B U G 3. Set a breakpoint in the source code
  • 42. S E T T I N G U P X D E B U G 3. Set a breakpoint in the source code • Line you know will be hit • Or break on first line
  • 43.
  • 44. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 45. S E T T I N G U P X D E B U G 4. Activate debugger on server • Browser plugin, add-on - The easiest Xdebug (Firefox) - Xdebug Helper (Chrome) - Xdebug Toggler (Safari) - Xdebug launcher (Opera)
  • 46. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 47. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 48. S E T T I N G U P X D E B U G 4. Activate debugger on server • URL - GET: &XDEBUG_SESSION_START=PHPSTORM - POST: XDEBUG_SESSION_START=PHPSTORM • Headers - Name: Cookie - Value: XDEBUG_SESSION=PHPSTORM • Bookmarklet
  • 49. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 50. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 51. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 52. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 53. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 54. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 55. S E T T I N G U P X D E B U G 4. Activate debugger on server
  • 56. S E T T I N G U P X D E B U G 5. Start a debug session in browser
  • 57. S E T T I N G U P X D E B U G 5. Start a debug session in browser • Click the debug button in toolbar • Add GET, POST, or COOKIE
  • 58. S E T T I N G U P X D E B U G 6. Reload the current page
  • 59. S E T T I N G U P X D E B U G 6. Reload the current page
  • 60. S E T T I N G U P X D E B U G 7. Set initial path mappings
  • 61. S E T T I N G U P X D E B U G 7. Set initial path mappings
  • 62. U S I N G X D E B U G
  • 63. U S I N G X D E B U G
  • 64. U S I N G X D E B U G • Breakpoints • Stepping through code • Watches • Console
  • 65. U S I N G X D E B U G
  • 66. U S I N G X D E B U G Breakpoints • Pause code execution at specific line • Allowed multiple breakpoints • Conditional breakpoints
  • 67. U S I N G X D E B U G Breakpoints • Place strategically • Not too early • Not too late • Not too many • Remember time limit, increase if needed • Use conditional breakpoints in loops
  • 68. U S I N G X D E B U G Breakpoints
  • 69. U S I N G X D E B U G Breakpoints
  • 70. U S I N G X D E B U G Stepping through code
  • 71. U S I N G X D E B U G Stepping through code • Resume Program (Play) • Stop • View Breakpoints • Disable All Breakpoints
  • 72. U S I N G X D E B U G Stepping through code • Step Over • Step Into • Force Step Into • Step Out • Run to Cursor
  • 73. U S I N G X D E B U G Stepping through code • Evaluate Expression • Show value addresses • Hide empty superglobal variables (on by default) • Add method to skip list
  • 74. U S I N G X D E B U G Watches
  • 75. U S I N G X D E B U G Watches • Live updates • Values • Expressions
  • 76. U S I N G X D E B U G Console
  • 77. U S I N G X D E B U G Console • Output from debugging expressions • Enter expressions to be evaluated
  • 78. S U M M A RY
  • 79. S U M M A RY • More efficient way to debug • Visibility into code • Ability to change code on the fly • Watch values change line by line • Better understanding of code path
  • 80. Q U E S T I O N S ? https://joind.in/talk/14128
  • 81. S O U R C E S • JetBrains documentation https://confluence.jetbrains.com/display/PhpStorm/Zero- configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm • Xdebug documentation https://xdebug.org/docs/install • David Stockton, php[architect], January 2015, https://www.phparch.com/wp- content/uploads/2015/01/levelup-xdebug-phparchitect-jan2015.pdf