2017 © Pedro Peláez
 

project xdebug-demo

A demo outlining the benefits of using Xdebug on your typical PHP development workflow.

image

jpcaparas/xdebug-demo

A demo outlining the benefits of using Xdebug on your typical PHP development workflow.

  • Thursday, June 8, 2017
  • by jpcaparas
  • Repository
  • 2 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Xdebug Demo

xdebug-logo, (*1)

A demo outlining the benefits of using Xdebug on your typical PHP development workflow., (*2)

Requirements

  1. PHP v5.6++ w/ Xdebug installed.
  2. An IDE that supports Xdebug. This demo uses PhpStorm.
  3. Google Chrome w/ the Xdebug helper extension installed.
  4. Shell access.

Installation

To get started with this project, run:, (*3)

composer create-project \
--prefer-source \
--stability=dev \
jpcaparas/xdebug-demo \
[dir-name]

Once cloned, run tests to ensure everything is intact:, (*4)

./vendor/bin/codecept run

Xdebug might already be installed on your machine; to find out, run:, (*5)

php -v

... which should result in an output similar to this:, (*6)

PHP 7.1.5 (cli) (built: May 13 2017 13:30:32) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Xdebug v2.5.1, Copyright (c) 2002-2017, by Derick Rethans

If you don't have the with Xdebug... line, you'll have to download, enable, and configure the Xdebug extension., (*7)

Atlassian has a good, multi-platform guide on how to install Xdebug., (*8)

Usage

Wiring everything up

Once you have Xdebug configured, mark breakpoints throughout your code base:, (*9)

Mark breakpoints, (*10)

Upon marking, ensure that your IDE has been set up to become a debug client., (*11)

Listen for incoming connections, (*12)

... and allow the browser to connect to the client., (*13)

Chrome browser extension, (*14)

Now spin up a built-in web server from the terminal and we'll start debugging:, (*15)

php -S localhost:8000 -t public

Connecting to the debug client

Open your browser on http://localhost:8000. You should see a form that asks for a GitHub username., (*16)

Assuming that you have added breakpoints to the ./src/Services/GitHubService.php file, your should be able to breakpoint into the code upon sending the POST request., (*17)

If the connection was successful, you'll be taken to the Debugger pane on PhpStorm, where you'll see a lot of stuff going on:, (*18)

, (*19)

At this point, all you need to do is familiarise yourself with the various commands at your disposal (e.g. frames, variables, console, stepping)., (*20)

More information about the various Debugger features can be seen here., (*21)

Gotchas

composer has become slower following Xdebug's installation. Is it possible to disable Xdebug on composer usage?, (*22)

Yes, append this nifty script on your ~/.bash_aliases file (or its equivalent):, (*23)

alias composer="php -n -d memory_limit=-1 $(which composer)"

The -n flag effectively disables PHP from reading the php.ini file (where Xdebug is defined)., (*24)

Resources

Coming soon..., (*25)

Attributions

This demo is part of Pixel Fusion Engineering Talks held every Friday, wherein we showcase tools and methodologies that empower developer productivity., (*26)

The Versions

08/06 2017

dev-master

9999999-dev

A demo outlining the benefits of using Xdebug on your typical PHP development workflow.

  Sources   Download

Unlicense

The Requires

 

The Development Requires

by JP Caparas