SlideShare a Scribd company logo
1 of 32
Download to read offline
Welcome!




PHP Barcelona - Barcelona, Spain
    Derick Rethans - dr@ez.no
 http://derickrethans.nl/talks.php
About Me

●   Dutchman living in Norway
●   eZ Systems A.S.
●   eZ Components project lead
●   PHP development
●   mcrypt, input_filter, date/time support, unicode
●   QA
I Do Not Need a Debugger

●   printf(), var_dump() and echo are good enough
I Do Not Need a Debugger
I Do Need a Debugger

●   Xdebug: An Open Source debugging tool
●   About 5 years old
●   Version 2 released a year ago
●   Works (at least) on Linux and Mac and Windows
How did it start?
Installing Xdebug
                Compiling

With PEAR:
   ● pecl install xdebug


Without PEAR:
   ● wget http://xdebug.org/files/xdebug-2.0.3.tgz

   ● tar -xvzf xdebug-2.0.3.tgz

   ● cd xdebug-2.0.3

   ● phpize

   ● ./configure

   ● make

   ● make install
Installing Xdebug
               Enabling

●   in php.ini add: zend_extension=/full/path/to/xdebug.so
●   Use zend_extension_debug for debug builds of PHP
Installing Xdebug
               On Windows

●   Download the .dll for your PHP version from
    http://xdebug.org/
●   in php.ini add: zend_extension_ts=c:phpxdebug.dll
Installing Xdebug
               Gotchas

●   --enable-versioning prevent Xdebug from loading
●   Zend's extensions (optimizer, debugger, cache) prohibit
    Xdebug (and other non-Zend zend-extensions) from
    loading
Protection

   ●Stack overflow in PHP
  ● Infinite recursion


Xdebug protects with:
xdebug.max_nesting_level=4
Help By Error Messages




... is kinda useles.




xdebug.collect_params=1 and xdebug.show_local_vars=1
Demo




demo
Debugging With Request Variables




xdebug.dump.GET=*
xdebug.dump.POST=username,password
Also for: COOKIE, ENV, FILES, REQUEST, SERVER and
SESSION
Pretty Printing Variables




<?php
ini_set( 'xdebug.var_display_max_data', 25 );
ini_set( 'xdebug.var_display_max_depth', 4 );

xdebug_var_dump(); // or just var_dump()
?>
How Many Functions

<?php
echo xdebug_get_function_count();
?>




<?php
echo xdebug_get_function_count();
?>
How Much Time Does It Take

<pre>
<?php
require_once 'ezc/Base/base.php';

function __autoload( $className )
{
    ezcBase::autoload( $className );
}

$cfg = ezcConfigurationManager::getInstance();
$cfg->init( 'ezcConfigurationIniReader', dirname( __FILE__ ) . '/examples' );

echo quot;Time Index: quot;, xdebug_time_index(), quot;nquot;;
$pw = $cfg->getSetting( 'settings', 'db', 'password' );
echo quot;The password is <$pw>.nquot;;
echo quot;Time Index: quot;, xdebug_time_index(), quot;nquot;;
?>
How Much Memory Does It Use

<pre>
<?php
require 'ezc_mail_setup.php';
error_reporting(E_ALL);

$parser = new ezcMailParser();
$set = new ezcMailFileSet( array( dirname(__FILE__).'/ezcmailtest.mail' ) );
echo quot;Memory: quot;, xdebug_memory_usage(), quot; bytesnnquot;;

$mail = $parser->parseMail( $set );
foreach( $mail as $mailPart )
{
    echo quot;From: {$mailPart->from->email}nquot;;
    echo quot;Subject: {$mailPart->subject}nquot;;
}
unset( $mail );

echo quot;nMaximum Memory: quot;, xdebug_peak_memory_usage(), quot; bytesnquot;;
?>
Execution trace




Some settings:
xdebug.auto_trace=1
xdebug.trace_output_dir=/tmp
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.trace_output_name=trace.%c

Specifiers:
http://xdebug.org/docs/execution_trace#trace_output_name
Execution trace to file
                           Automatic readable format




xdebug.auto_trace=1     ; enable tracing
xdebug.trace_format=1 ; selects computerized format
xdebug.trace_options=0 ; sets extra option (1 = append)
Execution trace
               Other functionality

●   HTML traces
●   Tracing only parts of an application with
    xdebug_start_trace() and xdebug_stop_trace().
●   Fetching the trace file name that is being used with
    xdebug_get_tracefile_name().
●   Changing how much data is shown with
    xdebug.var_display_max_children,
    xdebug.var_display_max_data and
    xdebug.var_display_max_depth.
Demo




demo
What Code Do I Use




Available functions:
xdebug_start_code_coverage();
xdebug_get_code_coverage();
xdebug_stop_code_coverage();
What Code Do I Use

Options to xdebug_start_code_coverage():
   ● XDEBUG_CC_UNUSED: Enables scanning of code to


      figure out which line has executable code.
   ● XDEBUG_CC_DEAD_CODE: Enables branch


      analyzation to figure out whether code can be executed.
http://kossu/coverage/index.html
Profiling
                           KCacheGrind's Flat Profile and Call List




xdebug.profiler_enable=1         ; enable profiler
xdebug.profile_output_dir=/tmp    ; output directory
xdebug.profile_output_name=cachegrind.out.%p
Profiling
KCacheGrind's Call Graph and Source Annotations
Demo




demo
Analyzing Running Scripts

  ●  DBGp, common Debugging protocol
   ● Cross-language: PHP, Python, Perl...

   ● Supported in Xdebug 2

   ● Clients: Komodo, Maguma Workbench, TruStudio (PHP


     Eclipse Plugin) and many other smaller ones
Other clients and plugins:
Activating the Remote Debugger

php.ini settings:
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.extended_info=1




On the shell:
export XDEBUG_CONFIG=quot;idekey=xdebugrocks
remote_enable=1quot;

With a browser:
http://pres/show.php?
XDEBUG_SESSION_START=xdebugrocks

With a firefox extension:
http://tinyurl.com/6otvm4
DBGp
                           DeBuGger Protocol

   ●   Input commands as quot;command line parametersquot;
   ●   property_get -n $foo -d 2 -i 81
   ●   Output data as documented XML:
data_length
[NULL]
<response command=quot;command_namequot; transaction_id=quot;transaction_idquot;/>
[NULL]

   ●   Cross-language: PHP, Python, Perl...
   ●   Supported in Xdebug 2
Demo




demo
Resources




Xdebug site: http://xdebug.org
Xdebug documentation: http://xdebug.org/docs.php
DBGp specification: http://xdebug.org/docs-dbgp.php
These slides: http://derickrethans.nl/talks.php
Questions?: derick@xdebug.org

More Related Content

What's hot

How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to productionSean Hess
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Eric Hogue
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from insidejulien pauli
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionjulien pauli
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4Wim Godden
 
A new way to develop with WordPress!
A new way to develop with WordPress!A new way to develop with WordPress!
A new way to develop with WordPress!David Sanchez
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHPEric Hogue
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDDEric Hogue
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 
PHP 5.6 New and Deprecated Features
PHP 5.6  New and Deprecated FeaturesPHP 5.6  New and Deprecated Features
PHP 5.6 New and Deprecated FeaturesMark Niebergall
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Gosuke Miyashita
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)julien pauli
 
Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Shinya Ohyanagi
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshopjulien pauli
 
Guarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingGuarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingEric Hogue
 
Артем Маркушев - JavaScript
Артем Маркушев - JavaScriptАртем Маркушев - JavaScript
Артем Маркушев - JavaScriptDataArt
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in PerlLaurent Dami
 
PHP Optimization
PHP OptimizationPHP Optimization
PHP Optimizationdjesch
 

What's hot (20)

The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
A new way to develop with WordPress!
A new way to develop with WordPress!A new way to develop with WordPress!
A new way to develop with WordPress!
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHP
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDD
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
PHP 5.6 New and Deprecated Features
PHP 5.6  New and Deprecated FeaturesPHP 5.6  New and Deprecated Features
PHP 5.6 New and Deprecated Features
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
 
Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
Guarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingGuarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous Testing
 
Артем Маркушев - JavaScript
Артем Маркушев - JavaScriptАртем Маркушев - JavaScript
Артем Маркушев - JavaScript
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
PHP Optimization
PHP OptimizationPHP Optimization
PHP Optimization
 

Similar to Xdebug - Derick Rethans - Barcelona PHP Conference 2008

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
 
Xdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP codeXdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP codeAdam Englander
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 DevelopmentDuke Dao
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Bastian Feder
 
Diagnosing WordPress: What to do when things go wrong
Diagnosing WordPress: What to do when things go wrongDiagnosing WordPress: What to do when things go wrong
Diagnosing WordPress: What to do when things go wrongWordCamp Sydney
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick RethansBachkoutou Toutou
 
Xdebug as a Drupal debugging tool
Xdebug as a Drupal debugging toolXdebug as a Drupal debugging tool
Xdebug as a Drupal debugging toolVladimir Melnic
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormMichelangelo van Dam
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
Eclipse HandsOn Workshop
Eclipse HandsOn WorkshopEclipse HandsOn Workshop
Eclipse HandsOn WorkshopBastian Feder
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebMikel Torres Ugarte
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Puppet
 
Tips
TipsTips
Tipsmclee
 

Similar to Xdebug - Derick Rethans - Barcelona PHP Conference 2008 (20)

Xdebug from a to x
Xdebug from a to xXdebug from a to x
Xdebug from a to x
 
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
 
Xdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP codeXdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP code
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Xdebug
XdebugXdebug
Xdebug
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Diagnosing WordPress: What to do when things go wrong
Diagnosing WordPress: What to do when things go wrongDiagnosing WordPress: What to do when things go wrong
Diagnosing WordPress: What to do when things go wrong
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick Rethans
 
Xdebug as a Drupal debugging tool
Xdebug as a Drupal debugging toolXdebug as a Drupal debugging tool
Xdebug as a Drupal debugging tool
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Eclipse HandsOn Workshop
Eclipse HandsOn WorkshopEclipse HandsOn Workshop
Eclipse HandsOn Workshop
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
 
Tips
TipsTips
Tips
 
Pecl Picks
Pecl PicksPecl Picks
Pecl Picks
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

Xdebug - Derick Rethans - Barcelona PHP Conference 2008

  • 1. Welcome! PHP Barcelona - Barcelona, Spain Derick Rethans - dr@ez.no http://derickrethans.nl/talks.php
  • 2. About Me ● Dutchman living in Norway ● eZ Systems A.S. ● eZ Components project lead ● PHP development ● mcrypt, input_filter, date/time support, unicode ● QA
  • 3. I Do Not Need a Debugger ● printf(), var_dump() and echo are good enough
  • 4. I Do Not Need a Debugger
  • 5. I Do Need a Debugger ● Xdebug: An Open Source debugging tool ● About 5 years old ● Version 2 released a year ago ● Works (at least) on Linux and Mac and Windows
  • 6. How did it start?
  • 7. Installing Xdebug Compiling With PEAR: ● pecl install xdebug Without PEAR: ● wget http://xdebug.org/files/xdebug-2.0.3.tgz ● tar -xvzf xdebug-2.0.3.tgz ● cd xdebug-2.0.3 ● phpize ● ./configure ● make ● make install
  • 8. Installing Xdebug Enabling ● in php.ini add: zend_extension=/full/path/to/xdebug.so ● Use zend_extension_debug for debug builds of PHP
  • 9. Installing Xdebug On Windows ● Download the .dll for your PHP version from http://xdebug.org/ ● in php.ini add: zend_extension_ts=c:phpxdebug.dll
  • 10. Installing Xdebug Gotchas ● --enable-versioning prevent Xdebug from loading ● Zend's extensions (optimizer, debugger, cache) prohibit Xdebug (and other non-Zend zend-extensions) from loading
  • 11. Protection ●Stack overflow in PHP ● Infinite recursion Xdebug protects with: xdebug.max_nesting_level=4
  • 12. Help By Error Messages ... is kinda useles. xdebug.collect_params=1 and xdebug.show_local_vars=1
  • 14. Debugging With Request Variables xdebug.dump.GET=* xdebug.dump.POST=username,password Also for: COOKIE, ENV, FILES, REQUEST, SERVER and SESSION
  • 15. Pretty Printing Variables <?php ini_set( 'xdebug.var_display_max_data', 25 ); ini_set( 'xdebug.var_display_max_depth', 4 ); xdebug_var_dump(); // or just var_dump() ?>
  • 16. How Many Functions <?php echo xdebug_get_function_count(); ?> <?php echo xdebug_get_function_count(); ?>
  • 17. How Much Time Does It Take <pre> <?php require_once 'ezc/Base/base.php'; function __autoload( $className ) { ezcBase::autoload( $className ); } $cfg = ezcConfigurationManager::getInstance(); $cfg->init( 'ezcConfigurationIniReader', dirname( __FILE__ ) . '/examples' ); echo quot;Time Index: quot;, xdebug_time_index(), quot;nquot;; $pw = $cfg->getSetting( 'settings', 'db', 'password' ); echo quot;The password is <$pw>.nquot;; echo quot;Time Index: quot;, xdebug_time_index(), quot;nquot;; ?>
  • 18. How Much Memory Does It Use <pre> <?php require 'ezc_mail_setup.php'; error_reporting(E_ALL); $parser = new ezcMailParser(); $set = new ezcMailFileSet( array( dirname(__FILE__).'/ezcmailtest.mail' ) ); echo quot;Memory: quot;, xdebug_memory_usage(), quot; bytesnnquot;; $mail = $parser->parseMail( $set ); foreach( $mail as $mailPart ) { echo quot;From: {$mailPart->from->email}nquot;; echo quot;Subject: {$mailPart->subject}nquot;; } unset( $mail ); echo quot;nMaximum Memory: quot;, xdebug_peak_memory_usage(), quot; bytesnquot;; ?>
  • 20. Execution trace to file Automatic readable format xdebug.auto_trace=1 ; enable tracing xdebug.trace_format=1 ; selects computerized format xdebug.trace_options=0 ; sets extra option (1 = append)
  • 21. Execution trace Other functionality ● HTML traces ● Tracing only parts of an application with xdebug_start_trace() and xdebug_stop_trace(). ● Fetching the trace file name that is being used with xdebug_get_tracefile_name(). ● Changing how much data is shown with xdebug.var_display_max_children, xdebug.var_display_max_data and xdebug.var_display_max_depth.
  • 23. What Code Do I Use Available functions: xdebug_start_code_coverage(); xdebug_get_code_coverage(); xdebug_stop_code_coverage();
  • 24. What Code Do I Use Options to xdebug_start_code_coverage(): ● XDEBUG_CC_UNUSED: Enables scanning of code to figure out which line has executable code. ● XDEBUG_CC_DEAD_CODE: Enables branch analyzation to figure out whether code can be executed. http://kossu/coverage/index.html
  • 25. Profiling KCacheGrind's Flat Profile and Call List xdebug.profiler_enable=1 ; enable profiler xdebug.profile_output_dir=/tmp ; output directory xdebug.profile_output_name=cachegrind.out.%p
  • 26. Profiling KCacheGrind's Call Graph and Source Annotations
  • 28. Analyzing Running Scripts ● DBGp, common Debugging protocol ● Cross-language: PHP, Python, Perl... ● Supported in Xdebug 2 ● Clients: Komodo, Maguma Workbench, TruStudio (PHP Eclipse Plugin) and many other smaller ones Other clients and plugins:
  • 29. Activating the Remote Debugger php.ini settings: xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.extended_info=1 On the shell: export XDEBUG_CONFIG=quot;idekey=xdebugrocks remote_enable=1quot; With a browser: http://pres/show.php? XDEBUG_SESSION_START=xdebugrocks With a firefox extension: http://tinyurl.com/6otvm4
  • 30. DBGp DeBuGger Protocol ● Input commands as quot;command line parametersquot; ● property_get -n $foo -d 2 -i 81 ● Output data as documented XML: data_length [NULL] <response command=quot;command_namequot; transaction_id=quot;transaction_idquot;/> [NULL] ● Cross-language: PHP, Python, Perl... ● Supported in Xdebug 2
  • 32. Resources Xdebug site: http://xdebug.org Xdebug documentation: http://xdebug.org/docs.php DBGp specification: http://xdebug.org/docs-dbgp.php These slides: http://derickrethans.nl/talks.php Questions?: derick@xdebug.org