Usefull Tools

debugger/profiler xdebug

Installation

sudo yum install php-pecl-xdebug

Profiler Configuration

php.ini
[xdebug]

; run profiler only if XDEBUG_PROFILE is GET or POST param or there is a cookie named XDEBUG_PROFILE
xdebug.profiler_enable_trigger=1

; run profiler only if XDEBUG_PROFILE is set to VZpSHymTZ1jZzPXT (e.g. https://192.168.0.122/lara/admin/Contract?XDEBUG_PROFILE=VZpSHymTZ1jZzPXT)
xdebug.profiler_enable_trigger_value=VZpSHymTZ1jZzPXT

; path to store cachegrind files in (must exist and be writeable for apache
; attention: if storing in /tmp or /var/tmp: these dirs are redirected to /tmp/systemd-private-*-httpd.service-*/tmp
xdebug.profiler_output_dir="/var/www/lara/xdebug"

Usage

  • cachegrind files can be viewed e.g. using kcachegrind
  • holding detailed timing informations (broke down to function level)
  • for an example watch the screenshot wherre you can see that asking the Envia API via cURL consumes ~30% of complete execution time
    Screenshot of how xdebug is used
  • see https://xdebug.org/docs and https://kcachegrind.github.io/html/Home.html for more information
  • xdebug seems also be able to work with several editors/IDEs – vim and PhpStorm to name two

laravel-debugbar

Installation

composer require barryvdh/laravel-debugbar

Configuration

config/app.php
'providers' => [
	...,
	'Barryvdh\Debugbar\ServiceProvider',
	...,
];

'aliases' => [
	...,
	'Debugbar' =>  'Barryvdh\Debugbar\Facade',
	...,
];

Usage

  • as default gives you a bar on bottom of the page containing runtime related informations (log entries, execution timeline, exceptions, SQL queries executed – including loading times, etc.)
  • also you can easily encapsulate codeblocks in start_measure() stop_measure() functions to extend the timeline with your own execution time informations
    Screenshot how the laravel debugger is used
  • much more can be done; read https://github.com/barryvdh/laravel-debugbar
  • laravel-debugbar is a wrapper for “PHP Debug Bar” – full description can be found at http://phpdebugbar.com/docs