Running Xdebug with Sublime Text from Command Line

Tags: July 11, 2015 6:15 PM
0 comments

Overview

Sometimes there is a case we spending more time on command line rather than on browser when developing a PHP application. It is true especially when we are in unit testing phase. Usually Xdebug remote debugging activated by sending XDEBUG_SESSION_START=session_key in query string or http post body. For debugging from command line we need to set environment variable XDEBUG_CONFIG="idkey=session_key".

Debugging with Sublime and Xdebug

Default Xdebug session name for Sublime Xdebug Client is "sublime.xdebug". Assuming all the configuration related with Xdebug and Sublime are done, here is the way to begin debugging from command line.

  1. Start Xdebug on Sublime by going to Tools » Xdebug » Start Debugging
  2. Set your break point somewhere in your code
  3. Run your PHP script on command line, here I'm using phpunit.
    $ XDEBUG_CONFIG="idkey=sublime.xdebug" phpunit app/tests/notifier/v1/UserLoginNotifierQueueTest.php
    
  4. Go back to Sublime and all the debugging window are presented, the execution still paused at the break point.
  5. We can start to examine variables or doing "Step-In/Out".

References

Share on Facebook Twitter

How to Detect Disconnected Client from Our Network

Tags: February 19, 2015 9:01 PM
0 comments

Overview

If you have a Linux box which act as gateway or Captive Portal, you might want to do something fancy when client get connected or disconnected from your box. As an example, you want to modify some iptables rules as soon as client leave your network.

Problem

You want to detect status of a machine as soon as it disconnected form your network. The arp command utility still displaying client which already gone from our network. The default cache time inside Linux kernel might be set for longer period of time.

Solution

Instead of using arp utility, we can use ip command utility as tool for displaying statistics of our "neighbors". Below is an example of showing status of our neighbors.

Share on Facebook Twitter