SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
Welcome!




                       ConFoo
        Montréal, Canada - March 9th, 2011
 Derick Rethans - derick@derickrethans.nl - twitter:
                      @derickr
              http://derickrethans.nl/talks.html
                      http://joind.in/2783
About Me



Derick Rethans




●   Dutchman living in London
●   PHP development
●   Author of the mcrypt, input_filter, dbus, translit
    and date/time extensions
●   Author of Xdebug
●   Contributor to the Apache Zeta Components
    Incubator project (formerly eZ Components)
●   Freelancer doing PHP (internals) development
Development Aid
Live Debugging
Profiling
Xdebug Pimps Your Ride
Error Messages
     Warning: DOMDocument::load() [domdocument.load]: Document is empty in
     /home/httpd/presentations,
     line: 1 in /home/httpd/pres2/show2.php on line 165
     _________________________________________________________________________________________________
     |( ! ) Warning: DOMDocument::load() [domdocument.load]: Document is empty in /home/httpd/         |
     |presentations,_line:_1_in_/home/httpd/pres2/show2.php_on_line_165________________________________|
     |Call_Stack_______________________________________________________________________________________|
     |#|Time__|Memory_|Function_______________________________________________________|Location________|
     |1|0.0013|_787720|{main}(_)______________________________________________________|../show2.php:0__|
     |2|0.0102|1398552|Presentation->display(_$slideNr_=_NULL_)_______________________|../show2.php:114|
     |3|0.0103|1400336|DOMDocument->load( '/home/httpd/pres2/presentations/'|../show2.php:165|
     |_|______|_______|)______________________________________________________________|________________|




 ●     xdebug.collect_include=?
 ●     xdebug.var_display_max_children=?
       xdebug.var_display_max_data=?
       xdebug.var_display_max_depth=?
 ●     xdebug.file_link_format=?
       xdebug.file_link_format=gvim://f@l
       xdebug.file_link_format=txmt://open/?url=file://f&line=l
       xdebug.file_link_format=???://f?l Windows:
       http://forums.netbeans.org/topic20597.html#85639 Linux:
       http://xdebug.org/docs/stack_trace#file_link_format
Error Messages
Pimped-Up with CSS

 ________________________________________________________________________________________
 |( ! ) Fatal error: Maximum execution time of 1 second exceeded in /home/httpd/html/test/|
 |xdebug/docs/stack.php_on_line_66________________________________________________________|
 |Call_Stack______________________________________________________________________________|
 |#|Time___________________|Memory|Function_|Location_____________________________________|
 |1|____________0.0004_____|691504|{main}(_)|../stack.php:0_______________________________|
 |2|____________0.0006_____|699472|foo(_)___|../stack.php:82______________________________|
 |Dump_$_SERVER___________________________________________________________________________|
 |$_SERVER['REQUEST_URI'] |string_'/test/xdebug/docs/stack.php?level=7'_(length=35)______|
 |Variables_in_local_scope_(#2)___________________________________________________________|
 |                     $a |array (size=5)                                                 |
 |                         |                                                                |
 |                         | 42 => boolean false                                            |
 |                         | 'foo' => int 9121240                                           |
 |                         | 43 =>                                                          |
 |                         |    object(stdClass)[1]                                         |
 |                         |      public 'bar' => int 100                                   |
 |                         |                                                                |
 |                         | 44 =>                                                          |
 |                         |    object(stdClass)[2]                                         |
 |_________________________|__45_=>_resource(4,_stream)___________________________________|
 |_____________________$i |int_2176225___________________________________________________|
Error Messages
Record and Delayed Display

 xdebug_start_error_collection()
 xdebug_stop_error_collection()
 xdebug_get_collected_errors()
  <?php
  xdebug_start_error_collection();
  ?>
  <html>
  <body>
  <div id='main'>
  ...
  </div>
  <div id='errors'>
      <?php echo xdebug_get_collected_errors(); ?>
  </div>
  </html>
Pretty Printing Variables

 array(3) { [0]=> NULL [1]=> float(3.141592654) [2]=> array(1) { ["dutch"]=> object(locale)#1 (6) {
 ["lang"]=> string(2) "nl" ["variation"]=> string(2000)
 "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc
 dabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc
 dabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc
 dabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc

 array
   0 => null
   1 => float 3.141592654
   2 =>
     array
        'dutch' =>
          object(locale)[1]
            public 'lang' => string 'nl' (length=2)
            public 'variation' => string 'abcdabcdabcdabcdabcdabcda'... (length=2000)
            public 'charsets' =>
              array
                0 => string 'iso-88591' (length=9)
                1 => string 'iso-8859-15' (length=11)
            private 'mb_supported' => boolean false
            protected 'self' =>
              &object(locale)[1]
            protected 'id' => int 1


Options:
 <?php
 ini_set( 'xdebug.var_display_max_data', 25 );
 ini_set( 'xdebug.var_display_max_depth', 4 );
 ini_set( 'xdebug.var_display_max_children', 32 );
 ?>
Turn off in php.ini or .htaccess with:
 xdebug.overload_var_dump = 0
Colours on the Command Line
*new in 2.2*




 xdebug.cli_color=1
Scream

●   PHP's @ operator hides warnings and errors
●   xdebug.scream=1 makes PHP ignore @
Recording headers

●   Xdebug collects all headers being set, implicitly
    and explicitly
●   It's very useful for testing and unit-tests
●   xdebug_get_headers()
 <?php
 session_start();

 setcookie( 'key', 'value', time() + 86400 );

 header( "Status: 403" );

 var_dump( xdebug_get_headers() );
 ?>
Tracing
Function trace

 TRACE START [2010-03-24 11:03:12]
     0.0022     787776   -> {main}() /home/httpd/pres2/show2.php:0
     0.0028     803160     -> require(/home/derick/dev/ezcomponents/trunk/Base/src/
 ezc_bootstrap.php)/home/httpd/pres2/show2.php:2
     0.0029     803552       -> dirname('/home/derick/dev/ezcomponents/trunk/Base/src/
 ezc_bootstrap.php')/home/derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php:12
     0.0030     803968       -> explode('/', '/home/derick/dev/ezcomponents/trunk/Base/src')/home/
 derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php:13
     0.0031     807352       -> count(array (0 => '', 1 => 'home', 2 => 'derick', 3 => 'dev', 4 =>
 'ezcomponents', 5 => 'trunk', 6 => 'Base', 7 => 'src'))/home/derick/dev/ezcomponents/trunk/Base/src/
 ezc_bootstrap.php:15
     0.0032     807800       -> array_slice(array (0 => '', 1 => 'home', 2 => 'derick', 3 => 'dev', 4
 => 'ezcomponents', 5 => 'trunk', 6 => 'Base', 7 => 'src'), 0, -2)/home/derick/dev/ezcomponents/
 trunk/Base/src/ezc_bootstrap.php:17
     0.0033     808952       -> join('/', array (0 => '', 1 => 'home', 2 => 'derick', 3 => 'dev', 4
 => 'ezcomponents', 5 => 'trunk'))/home/derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php:17
     0.0065    1002544       -> require(/home/derick/dev/ezcomponents/trunk/Base/src/base.php)/home/
 derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php:18




Some settings:
 xdebug.auto_trace=1
 xdebug.trace_output_dir=/tmp
 xdebug.collect_params=1
 xdebug.collect_return=1
 xdebug.collect_includes=1
 xdebug.collect_assignments=1
Function 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)
Function 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
Swatting Bugs
Live Debugging

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


Clients:
● Eclipse/PDT (Java based — free)

● Komodo (Linux, Windows, Mac — commercial)

● MacGDBp (free)

● Netbeans (Java-based — free)

● PHPStorm (Java-based — commercial)

● Zend Studio for Eclipse (Eclipse-based —


  commercial)
● Stand-alone client (Linux (for now)):

● (and many others: )
Activating the Remote Debugger
php.ini settings:
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
php.ini settings:
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_connect_back=1
On the shell:
export XDEBUG_CONFIG="idekey=xdebugrocks"
With a browser:
http://pres/show.php?
XDEBUG_SESSION_START=xdebugrocks
http://pres/show.php?XDEBUG_SESSION_STOP=1
With browser extensions:
easy Xdebug (FireFox), Xdebug Helper (Chrome), Xdebug
Toggler for Safari, Xdebug launcher for Opera:
Debugging Connections
Single-user
Debugging Connections
Multi-user
demo
Profiling
Profiling
KCacheGrind's Flat Profile and Call List




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




 ●   Call graph
 ●   Area shows time spend
 ●   Stacked to show callees
 ●   Source annotations
 ●   Number of calls
 ●   Total time per function
demo
Xdebug

●   It's Open Source and free (as in "free beer")
●   Working on Xdebug takes up a lot of spare time
●   I don't have a lot of spare time
Resources




 ●   Xdebug site: http://xdebug.org
 ●   Xdebug documentation:
     http://xdebug.org/docs.php
 ●   DBGp specification: http://xdebug.org/docs-
     dbgp.php
 ●   Rate this talk! :-:joindin:-:
 ●   If you like Xdebug: http://xdebug.org/donate.php
 ●   These slides: http://derickrethans.nl/talks.html

Weitere ähnliche Inhalte

Was ist angesagt?

Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Formacion en movilidad: Conceptos de desarrollo en iOS (IV) Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Formacion en movilidad: Conceptos de desarrollo en iOS (IV) Mobivery
 
Error based blind sqli
Error based blind sqliError based blind sqli
Error based blind sqliDarkZtone Zone
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConRafael Dohms
 
The Etsy Shard Architecture: Starts With S and Ends With Hard
The Etsy Shard Architecture: Starts With S and Ends With HardThe Etsy Shard Architecture: Starts With S and Ends With Hard
The Etsy Shard Architecture: Starts With S and Ends With Hardjgoulah
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoMohamed Mosaad
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And AnishOSSCube
 
PHP Session - Mcq ppt
PHP Session - Mcq ppt PHP Session - Mcq ppt
PHP Session - Mcq ppt Shaheen Shaikh
 
Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4Fabien Potencier
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usagePavel Makhrinsky
 
Asynchronous JS in Odoo
Asynchronous JS in OdooAsynchronous JS in Odoo
Asynchronous JS in OdooOdoo
 
Building High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterBuilding High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterMithun T. Dhar
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Fabien Potencier
 
Dependency injection - phpday 2010
Dependency injection - phpday 2010Dependency injection - phpday 2010
Dependency injection - phpday 2010Fabien Potencier
 

Was ist angesagt? (20)

Entity api
Entity apiEntity api
Entity api
 
Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Formacion en movilidad: Conceptos de desarrollo en iOS (IV) Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
 
Error based blind sqli
Error based blind sqliError based blind sqli
Error based blind sqli
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
 
The Etsy Shard Architecture: Starts With S and Ends With Hard
The Etsy Shard Architecture: Starts With S and Ends With HardThe Etsy Shard Architecture: Starts With S and Ends With Hard
The Etsy Shard Architecture: Starts With S and Ends With Hard
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup Cairo
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
 
PHP Session - Mcq ppt
PHP Session - Mcq ppt PHP Session - Mcq ppt
PHP Session - Mcq ppt
 
Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usage
 
SOLID Ruby SOLID Rails
SOLID Ruby SOLID RailsSOLID Ruby SOLID Rails
SOLID Ruby SOLID Rails
 
Asynchronous JS in Odoo
Asynchronous JS in OdooAsynchronous JS in Odoo
Asynchronous JS in Odoo
 
Data Validation models
Data Validation modelsData Validation models
Data Validation models
 
Building High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterBuilding High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 Firestarter
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
 
Dependency injection - phpday 2010
Dependency injection - phpday 2010Dependency injection - phpday 2010
Dependency injection - phpday 2010
 
HCE tutorial
HCE tutorialHCE tutorial
HCE tutorial
 

Andere mochten auch

Technote Index Map Help
Technote Index Map HelpTechnote Index Map Help
Technote Index Map Helpguest0e7fb2
 
いちばん簡単なconcrete5テーマ
いちばん簡単なconcrete5テーマいちばん簡単なconcrete5テーマ
いちばん簡単なconcrete5テーマHideki MACHIDA
 
Developing Your Ultimate Package
Developing Your Ultimate PackageDeveloping Your Ultimate Package
Developing Your Ultimate PackageSimon Collison
 
The Original Hacker número 11.
The Original Hacker número 11.The Original Hacker número 11.
The Original Hacker número 11.Huehue 1
 
La evolución de los medios de información
La evolución de los medios de informaciónLa evolución de los medios de información
La evolución de los medios de informaciónYolanda Santana
 
password (facebook)
password (facebook) password (facebook)
password (facebook) Mr. FM
 
concrete5 5.7でテーマ作ってみよう 超初級編
concrete5 5.7でテーマ作ってみよう超初級編concrete5 5.7でテーマ作ってみよう超初級編
concrete5 5.7でテーマ作ってみよう 超初級編Yuriko Kamimori
 
Real Developer Tools for WordPress by Stefan Didak
Real Developer Tools for WordPress by Stefan DidakReal Developer Tools for WordPress by Stefan Didak
Real Developer Tools for WordPress by Stefan DidakEast Bay WordPress Meetup
 
TYPO3 CMS 7.1 - Die Neuerungen - pluswerk
TYPO3 CMS 7.1 - Die Neuerungen - pluswerkTYPO3 CMS 7.1 - Die Neuerungen - pluswerk
TYPO3 CMS 7.1 - Die Neuerungen - pluswerkdie.agilen GmbH
 
A portrait chapter_1
A portrait chapter_1A portrait chapter_1
A portrait chapter_1mellamogaby
 
TYPO3 CMS 6.2 LTS - Die Neuerungen
TYPO3 CMS 6.2 LTS - Die NeuerungenTYPO3 CMS 6.2 LTS - Die Neuerungen
TYPO3 CMS 6.2 LTS - Die Neuerungendie.agilen GmbH
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity FrameworksRich Helton
 

Andere mochten auch (20)

NASL
NASLNASL
NASL
 
Clipagem tarumã setembro 2010
Clipagem tarumã   setembro 2010Clipagem tarumã   setembro 2010
Clipagem tarumã setembro 2010
 
Livestock and Land
Livestock and LandLivestock and Land
Livestock and Land
 
cPanel User Manual
cPanel User ManualcPanel User Manual
cPanel User Manual
 
C lipagem tarumã maio 2010
C lipagem tarumã   maio 2010C lipagem tarumã   maio 2010
C lipagem tarumã maio 2010
 
Introduction Php
Introduction PhpIntroduction Php
Introduction Php
 
Technote Index Map Help
Technote Index Map HelpTechnote Index Map Help
Technote Index Map Help
 
いちばん簡単なconcrete5テーマ
いちばん簡単なconcrete5テーマいちばん簡単なconcrete5テーマ
いちばん簡単なconcrete5テーマ
 
Developing Your Ultimate Package
Developing Your Ultimate PackageDeveloping Your Ultimate Package
Developing Your Ultimate Package
 
C lipagem tarumã outubro 2010
C lipagem tarumã   outubro 2010C lipagem tarumã   outubro 2010
C lipagem tarumã outubro 2010
 
The Original Hacker número 11.
The Original Hacker número 11.The Original Hacker número 11.
The Original Hacker número 11.
 
La evolución de los medios de información
La evolución de los medios de informaciónLa evolución de los medios de información
La evolución de los medios de información
 
password (facebook)
password (facebook) password (facebook)
password (facebook)
 
concrete5 5.7でテーマ作ってみよう 超初級編
concrete5 5.7でテーマ作ってみよう超初級編concrete5 5.7でテーマ作ってみよう超初級編
concrete5 5.7でテーマ作ってみよう 超初級編
 
Real Developer Tools for WordPress by Stefan Didak
Real Developer Tools for WordPress by Stefan DidakReal Developer Tools for WordPress by Stefan Didak
Real Developer Tools for WordPress by Stefan Didak
 
TYPO3 CMS 7.1 - Die Neuerungen - pluswerk
TYPO3 CMS 7.1 - Die Neuerungen - pluswerkTYPO3 CMS 7.1 - Die Neuerungen - pluswerk
TYPO3 CMS 7.1 - Die Neuerungen - pluswerk
 
A portrait chapter_1
A portrait chapter_1A portrait chapter_1
A portrait chapter_1
 
Google Dorks
Google DorksGoogle Dorks
Google Dorks
 
TYPO3 CMS 6.2 LTS - Die Neuerungen
TYPO3 CMS 6.2 LTS - Die NeuerungenTYPO3 CMS 6.2 LTS - Die Neuerungen
TYPO3 CMS 6.2 LTS - Die Neuerungen
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity Frameworks
 

Ähnlich wie Xdebug confoo11

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
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Shinya Ohyanagi
 
Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Michelangelo van Dam
 
Meet Magento Belarus debug Pavel Novitsky (eng)
Meet Magento Belarus debug Pavel Novitsky (eng)Meet Magento Belarus debug Pavel Novitsky (eng)
Meet Magento Belarus debug Pavel Novitsky (eng)Pavel Novitsky
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansiblebcoca
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your CodeDrupalDay
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?Roman Elizarov
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptDarren Mothersele
 
Zend Framework 2 - Basic Components
Zend Framework 2  - Basic ComponentsZend Framework 2  - Basic Components
Zend Framework 2 - Basic ComponentsMateusz Tymek
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
Introducing PHP Data Objects
Introducing PHP Data ObjectsIntroducing PHP Data Objects
Introducing PHP Data Objectswebhostingguy
 
Building source code level profiler for C++.pdf
Building source code level profiler for C++.pdfBuilding source code level profiler for C++.pdf
Building source code level profiler for C++.pdfssuser28de9e
 
Web internship Yii Framework
Web internship  Yii FrameworkWeb internship  Yii Framework
Web internship Yii FrameworkNoveo
 
.NET 7 Performance Improvements_10_03_2023.pdf
.NET 7 Performance Improvements_10_03_2023.pdf.NET 7 Performance Improvements_10_03_2023.pdf
.NET 7 Performance Improvements_10_03_2023.pdfMirco Vanini
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008phpbarcelona
 
Extending MariaDB with user-defined functions
Extending MariaDB with user-defined functionsExtending MariaDB with user-defined functions
Extending MariaDB with user-defined functionsMariaDB plc
 

Ähnlich wie Xdebug confoo11 (20)

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
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
Smarty
SmartySmarty
Smarty
 
Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010
 
Meet Magento Belarus debug Pavel Novitsky (eng)
Meet Magento Belarus debug Pavel Novitsky (eng)Meet Magento Belarus debug Pavel Novitsky (eng)
Meet Magento Belarus debug Pavel Novitsky (eng)
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
How to fake_properly
How to fake_properlyHow to fake_properly
How to fake_properly
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
 
Zend Framework 2 - Basic Components
Zend Framework 2  - Basic ComponentsZend Framework 2  - Basic Components
Zend Framework 2 - Basic Components
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
Introducing PHP Data Objects
Introducing PHP Data ObjectsIntroducing PHP Data Objects
Introducing PHP Data Objects
 
Building source code level profiler for C++.pdf
Building source code level profiler for C++.pdfBuilding source code level profiler for C++.pdf
Building source code level profiler for C++.pdf
 
Web internship Yii Framework
Web internship  Yii FrameworkWeb internship  Yii Framework
Web internship Yii Framework
 
.NET 7 Performance Improvements_10_03_2023.pdf
.NET 7 Performance Improvements_10_03_2023.pdf.NET 7 Performance Improvements_10_03_2023.pdf
.NET 7 Performance Improvements_10_03_2023.pdf
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
 
Extending MariaDB with user-defined functions
Extending MariaDB with user-defined functionsExtending MariaDB with user-defined functions
Extending MariaDB with user-defined functions
 

Mehr von Bachkoutou Toutou

Making php see, confoo 2011
Making php see, confoo 2011 Making php see, confoo 2011
Making php see, confoo 2011 Bachkoutou Toutou
 
Sean coates fifty things and tricks, confoo 2011
Sean coates fifty things and tricks, confoo 2011Sean coates fifty things and tricks, confoo 2011
Sean coates fifty things and tricks, confoo 2011Bachkoutou Toutou
 
hacking your website with vega, confoo2011
hacking your website with vega, confoo2011hacking your website with vega, confoo2011
hacking your website with vega, confoo2011Bachkoutou Toutou
 
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011Bachkoutou Toutou
 
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011Bachkoutou Toutou
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Bachkoutou Toutou
 
Connecting web Applications with Desktop, confoo 2011
Connecting web Applications with Desktop, confoo 2011Connecting web Applications with Desktop, confoo 2011
Connecting web Applications with Desktop, confoo 2011Bachkoutou Toutou
 
Connecting Web Application and Desktop, confoo 2011, qafoo
Connecting Web Application and Desktop, confoo 2011, qafooConnecting Web Application and Desktop, confoo 2011, qafoo
Connecting Web Application and Desktop, confoo 2011, qafooBachkoutou Toutou
 
99 problems but the search aint one, confoo 2011, andrei zmievski
99 problems but the search aint one, confoo 2011, andrei zmievski99 problems but the search aint one, confoo 2011, andrei zmievski
99 problems but the search aint one, confoo 2011, andrei zmievskiBachkoutou Toutou
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick RethansBachkoutou Toutou
 
WebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesWebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesBachkoutou Toutou
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011Bachkoutou Toutou
 
Confoo 2011 - Advanced OO Patterns
Confoo 2011 - Advanced OO PatternsConfoo 2011 - Advanced OO Patterns
Confoo 2011 - Advanced OO PatternsBachkoutou Toutou
 

Mehr von Bachkoutou Toutou (14)

Making php see, confoo 2011
Making php see, confoo 2011 Making php see, confoo 2011
Making php see, confoo 2011
 
Sean coates fifty things and tricks, confoo 2011
Sean coates fifty things and tricks, confoo 2011Sean coates fifty things and tricks, confoo 2011
Sean coates fifty things and tricks, confoo 2011
 
hacking your website with vega, confoo2011
hacking your website with vega, confoo2011hacking your website with vega, confoo2011
hacking your website with vega, confoo2011
 
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
 
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011
 
Connecting web Applications with Desktop, confoo 2011
Connecting web Applications with Desktop, confoo 2011Connecting web Applications with Desktop, confoo 2011
Connecting web Applications with Desktop, confoo 2011
 
Connecting Web Application and Desktop, confoo 2011, qafoo
Connecting Web Application and Desktop, confoo 2011, qafooConnecting Web Application and Desktop, confoo 2011, qafoo
Connecting Web Application and Desktop, confoo 2011, qafoo
 
99 problems but the search aint one, confoo 2011, andrei zmievski
99 problems but the search aint one, confoo 2011, andrei zmievski99 problems but the search aint one, confoo 2011, andrei zmievski
99 problems but the search aint one, confoo 2011, andrei zmievski
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick Rethans
 
WebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesWebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coates
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
 
Apc Memcached Confoo 2011
Apc Memcached Confoo 2011Apc Memcached Confoo 2011
Apc Memcached Confoo 2011
 
Confoo 2011 - Advanced OO Patterns
Confoo 2011 - Advanced OO PatternsConfoo 2011 - Advanced OO Patterns
Confoo 2011 - Advanced OO Patterns
 

Xdebug confoo11

  • 1. Welcome! ConFoo Montréal, Canada - March 9th, 2011 Derick Rethans - derick@derickrethans.nl - twitter: @derickr http://derickrethans.nl/talks.html http://joind.in/2783
  • 2. About Me Derick Rethans ● Dutchman living in London ● PHP development ● Author of the mcrypt, input_filter, dbus, translit and date/time extensions ● Author of Xdebug ● Contributor to the Apache Zeta Components Incubator project (formerly eZ Components) ● Freelancer doing PHP (internals) development
  • 5. Error Messages Warning: DOMDocument::load() [domdocument.load]: Document is empty in /home/httpd/presentations, line: 1 in /home/httpd/pres2/show2.php on line 165 _________________________________________________________________________________________________ |( ! ) Warning: DOMDocument::load() [domdocument.load]: Document is empty in /home/httpd/ | |presentations,_line:_1_in_/home/httpd/pres2/show2.php_on_line_165________________________________| |Call_Stack_______________________________________________________________________________________| |#|Time__|Memory_|Function_______________________________________________________|Location________| |1|0.0013|_787720|{main}(_)______________________________________________________|../show2.php:0__| |2|0.0102|1398552|Presentation->display(_$slideNr_=_NULL_)_______________________|../show2.php:114| |3|0.0103|1400336|DOMDocument->load( &apos;/home/httpd/pres2/presentations/&apos;|../show2.php:165| |_|______|_______|)______________________________________________________________|________________| ● xdebug.collect_include=? ● xdebug.var_display_max_children=? xdebug.var_display_max_data=? xdebug.var_display_max_depth=? ● xdebug.file_link_format=? xdebug.file_link_format=gvim://f@l xdebug.file_link_format=txmt://open/?url=file://f&line=l xdebug.file_link_format=???://f?l Windows: http://forums.netbeans.org/topic20597.html#85639 Linux: http://xdebug.org/docs/stack_trace#file_link_format
  • 6. Error Messages Pimped-Up with CSS ________________________________________________________________________________________ |( ! ) Fatal error: Maximum execution time of 1 second exceeded in /home/httpd/html/test/| |xdebug/docs/stack.php_on_line_66________________________________________________________| |Call_Stack______________________________________________________________________________| |#|Time___________________|Memory|Function_|Location_____________________________________| |1|____________0.0004_____|691504|{main}(_)|../stack.php:0_______________________________| |2|____________0.0006_____|699472|foo(_)___|../stack.php:82______________________________| |Dump_$_SERVER___________________________________________________________________________| |$_SERVER['REQUEST_URI'] |string_'/test/xdebug/docs/stack.php?level=7'_(length=35)______| |Variables_in_local_scope_(#2)___________________________________________________________| | $a |array (size=5) | | | | | | 42 => boolean false | | | 'foo' => int 9121240 | | | 43 => | | | object(stdClass)[1] | | | public 'bar' => int 100 | | | | | | 44 => | | | object(stdClass)[2] | |_________________________|__45_=>_resource(4,_stream)___________________________________| |_____________________$i |int_2176225___________________________________________________|
  • 7. Error Messages Record and Delayed Display xdebug_start_error_collection() xdebug_stop_error_collection() xdebug_get_collected_errors() <?php xdebug_start_error_collection(); ?> <html> <body> <div id='main'> ... </div> <div id='errors'> <?php echo xdebug_get_collected_errors(); ?> </div> </html>
  • 8. Pretty Printing Variables array(3) { [0]=> NULL [1]=> float(3.141592654) [2]=> array(1) { ["dutch"]=> object(locale)#1 (6) { ["lang"]=> string(2) "nl" ["variation"]=> string(2000) "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc dabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc dabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc dabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc array 0 => null 1 => float 3.141592654 2 => array 'dutch' => object(locale)[1] public 'lang' => string 'nl' (length=2) public 'variation' => string 'abcdabcdabcdabcdabcdabcda'... (length=2000) public 'charsets' => array 0 => string 'iso-88591' (length=9) 1 => string 'iso-8859-15' (length=11) private 'mb_supported' => boolean false protected 'self' => &object(locale)[1] protected 'id' => int 1 Options: <?php ini_set( 'xdebug.var_display_max_data', 25 ); ini_set( 'xdebug.var_display_max_depth', 4 ); ini_set( 'xdebug.var_display_max_children', 32 ); ?> Turn off in php.ini or .htaccess with: xdebug.overload_var_dump = 0
  • 9. Colours on the Command Line *new in 2.2* xdebug.cli_color=1
  • 10. Scream ● PHP's @ operator hides warnings and errors ● xdebug.scream=1 makes PHP ignore @
  • 11. Recording headers ● Xdebug collects all headers being set, implicitly and explicitly ● It's very useful for testing and unit-tests ● xdebug_get_headers() <?php session_start(); setcookie( 'key', 'value', time() + 86400 ); header( "Status: 403" ); var_dump( xdebug_get_headers() ); ?>
  • 13. Function trace TRACE START [2010-03-24 11:03:12]     0.0022     787776   -> {main}() /home/httpd/pres2/show2.php:0     0.0028     803160     -> require(/home/derick/dev/ezcomponents/trunk/Base/src/ ezc_bootstrap.php)/home/httpd/pres2/show2.php:2     0.0029     803552       -> dirname('/home/derick/dev/ezcomponents/trunk/Base/src/ ezc_bootstrap.php')/home/derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php:12     0.0030     803968       -> explode('/', '/home/derick/dev/ezcomponents/trunk/Base/src')/home/ derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php:13     0.0031     807352       -> count(array (0 => '', 1 => 'home', 2 => 'derick', 3 => 'dev', 4 => 'ezcomponents', 5 => 'trunk', 6 => 'Base', 7 => 'src'))/home/derick/dev/ezcomponents/trunk/Base/src/ ezc_bootstrap.php:15     0.0032     807800       -> array_slice(array (0 => '', 1 => 'home', 2 => 'derick', 3 => 'dev', 4 => 'ezcomponents', 5 => 'trunk', 6 => 'Base', 7 => 'src'), 0, -2)/home/derick/dev/ezcomponents/ trunk/Base/src/ezc_bootstrap.php:17     0.0033     808952       -> join('/', array (0 => '', 1 => 'home', 2 => 'derick', 3 => 'dev', 4 => 'ezcomponents', 5 => 'trunk'))/home/derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php:17     0.0065    1002544       -> require(/home/derick/dev/ezcomponents/trunk/Base/src/base.php)/home/ derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php:18 Some settings: xdebug.auto_trace=1 xdebug.trace_output_dir=/tmp xdebug.collect_params=1 xdebug.collect_return=1 xdebug.collect_includes=1 xdebug.collect_assignments=1
  • 14. Function 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)
  • 15. Function 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.
  • 16. demo
  • 18. Live Debugging ● DBGp, common Debugging protocol ● Cross-language: PHP, Python, Perl... Clients: ● Eclipse/PDT (Java based — free) ● Komodo (Linux, Windows, Mac — commercial) ● MacGDBp (free) ● Netbeans (Java-based — free) ● PHPStorm (Java-based — commercial) ● Zend Studio for Eclipse (Eclipse-based — commercial) ● Stand-alone client (Linux (for now)): ● (and many others: )
  • 19. Activating the Remote Debugger php.ini settings: xdebug.remote_enable=1 xdebug.remote_host=localhost xdebug.remote_port=9000 php.ini settings: xdebug.remote_enable=1 xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.remote_connect_back=1 On the shell: export XDEBUG_CONFIG="idekey=xdebugrocks" With a browser: http://pres/show.php? XDEBUG_SESSION_START=xdebugrocks http://pres/show.php?XDEBUG_SESSION_STOP=1 With browser extensions: easy Xdebug (FireFox), Xdebug Helper (Chrome), Xdebug Toggler for Safari, Xdebug launcher for Opera:
  • 22.
  • 23.
  • 24. demo
  • 26. Profiling KCacheGrind's Flat Profile and Call List xdebug.profiler_enable=1 ; enable profiler xdebug.profiler_output_dir=/tmp ; output directory xdebug.profiler_output_name=cachegrind.out.%p
  • 27. Profiling KCacheGrind's Call Graph and Source Annotations ● Call graph ● Area shows time spend ● Stacked to show callees ● Source annotations ● Number of calls ● Total time per function
  • 28. demo
  • 29. Xdebug ● It's Open Source and free (as in "free beer") ● Working on Xdebug takes up a lot of spare time ● I don't have a lot of spare time
  • 30. Resources ● Xdebug site: http://xdebug.org ● Xdebug documentation: http://xdebug.org/docs.php ● DBGp specification: http://xdebug.org/docs- dbgp.php ● Rate this talk! :-:joindin:-: ● If you like Xdebug: http://xdebug.org/donate.php ● These slides: http://derickrethans.nl/talks.html