Categories
Mac PHP

Debugging with XDebug and PhpStorm on MacOS X

In an earlier post I demonstrated how to install PHP5.4 using brew. Today, I required xdebug for debugging purposes and found it quite easy to install via homebrew.

Install XDebug for PHP
It’s as simple as issuing the command:

Enabling XDebug
I had to add the extension to my php.ini file:

Follow the output of the brew info output of the package you installed (either php53 or php54):

To enable remote debugging, I also added these lines:

Debugging Web Applications
In the run configuration, add “Web Application” type. Configure the server and path as usual. When setup, you shall notice the debug button is active. Setup some break points and hit the debug button.

You can also use the “Listen PHP Debug Connection” option along with some xdebug bookmarklet for quick debugging.

Debugging Command Line Scripts
To debug command line scripts, first issue this command on terminal:

PS: I added the line to my ~/.bash_profile so that I don’t have to type it every time I login to bash shell.

Turn on incoming connections by clicking the “Start Listen PHP Debug Connection” button. Set some break points and then run the script from command line.

Categories
Mac Python

Setting up Python, MySQL Module and Django on Mac OS X Lion

I setup Python and Django using homebrew the easy way. I am going to detail the process now.

Install Python

The command should first install any dependencies for Python and then install the latest version from source code.

Adding Python to PATH

We need to edit our ~/.bash_profile to add “/usr/local/share/python” to the path variable. I added the following line to my bash profile:

I reloaded the profile by issuing:

This makes the python tools and toys accessible from my terminal.

Install MySQL Module

It’s recommended that you already have “mysql” installed from brew to build the mysql module. I already had it installed so it was a painless installation for me. I just issued the command:

Install Django
I am going to keep using the PIP awesomeness! Let’s hit:

It will install django with any dependencies. You can now invoke the “django-admin.py” command from your terminal. However, I prefer the command be “django-admin”, instead of “django-admin.py”. So I created the following alias in my ~/.bash_profile:

Isn’t it simple? 😀

Categories
Mac

Mac OS X: Using Sublime Text 2 from Command Line

Sublime Text 2 is an awesome text editor available free from – http://www.sublimetext.com/2 . I have been using the editor for almost every text editing purposes (when I am not using an IDE).

(1) First create a symlink to the original sublime text 2 executable:

Here, I already had the directory ~/bin created. Please create it yourself. Or you might want to create the symlink in /usr/local/bin or /usr/bin.

(2) To use it as the Unix editor, set this in your ~/.bash_profile