Skip to content

QwertyZW/php-debug

 
 

Repository files navigation

Atom PHP Debugging Package

Debug PHP code using the Xdebug PHP Extension.

Features

  • Add Breakpoints
  • Step through debugging (Over, In, Out)
  • Stack and Context views
  • Add Watchpoints to inspect current values of variables

This is currently an alpha release, and still in active development.

Getting Started

Install Xdebug

You may already have Xdebug installed. Check the results of the phpinfo function for xdebug information.
If no xdebug section exists, you likely need to install this. *nix users can likely find it within their package manager of choice. Alternative installation or compiling instructions are available here.

Setting up Xdebug

xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1    # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true

With these settings, PHP will connect to your editor for every script it executes. The alternative is to switch xdebug.remote_autostart to false, and install an Xdebug helper extension for your browser of choice, such as:

These browser extensions will give you a button within your browser to enable/disable Xdebug. It is also possible to run a php script from the command line with Xdebug enabled. You can find more information on this at the Xdebug documentation for Starting The Debugger. See can find a complete list and explanation of Xdebug settings here.

Start Debugging

To begin debugging:

  1. Open up your PHP file in atom
  2. Move the cursor to a line you want to break on, and set a breakpoint by pressing Alt+F9 or selecting Toggle Breakpoint from the Command Palette (ctrl+shift+p) or the php-debug menu (Packages -> php-debug->Toggle Breakpoint). This will highlight the line number green, to indicate the presence of a breakpoint.
  3. Open up the debug view by pressing ctrl+alt+d, or selecting 'Toggle Debugging' from the Command Palette or php-debug menu.
  4. Start the script with Xdebug enabled. If everything is setup correctly, the entire line of the breakpoint will be highlighted in green, indicating the current line of the script.

If everything worked correctly, you can now use the various buttons/commands to step through the script.

Settings

Put the following in your config.cson

"php-debug":
  {
    ServerPort: 9000
    PathMaps: [
      "remotepath;localpath"
      "/base/path/on/remote/system;C:\\base\\path\\on\\local\\system"
    ]
  }

Server Port

This is the port that the atom client will listen on. Defaults to 9000

Path Maps

If debugging code that resides on a remote machine, use pathmaps to map a path on the remote machine to a path on the local machine.

About

Atom Text Editor package for PHP debugging

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CoffeeScript 93.8%
  • CSS 4.8%
  • PHP 1.4%