Compass In Hand

Guiding The Geek In You

Transform gEdit into the Ultimate PHP IDE

Use Gnome? Love gEdit? Me too. In fact I love this little brother to Notepad++ so much that I’ve begun tweaking it into an IDE, and it turns out this little brother is growing up fast.

An important function of any Integrated Development Environment – or IDE – is that it provide a built-in compiler or interpreter.  Yet PHP is a server side language so getting it to place nicely outside of a web browser is tricky, but far from impossible.

In fact PHP scripts, like PowerShell or Perl, can be run from the command line. For example to run some_script.php on a machine with PHP installed and configured properly simply open a terminal prompt and type:

php5 directory_name/some_script.php

Bridging The Gap

So how to bridge the gap from CLI to IDE? External Tools.

First, enable the External Tools plugin. Go to the Edit drop down menu, select Preferences, click the Plugins tab, and select the External Tools check box (should be near the top somewhere).

Now, with External Tools selected click the Configure Plugin button to open the External Tools Manager window. Four tools have already been configured for you under “All Languages” – but we’re going to make our own! Find and click the little notepad icon near the bottom left corner of the manager window, which creates a new entry under “All Languages”. Name this entry “Run” (you can change it later).

In the Edit window enter the following code:


php5 ${DIR}/${FILE}

These BASH commands assign the current PHP script’s directory to DIR and the script’s name to FILE, and then executes the same command we typed above.

In the Shortcut Key field choose a cool key combo to invoke the tool. I like asciitilde (the ~ symbol). In the Save drop down I recommend selecting Current document so your key combo also saves your script before interpreting it.

In the Output drop down pick “Display in bottom pane”, which causes the output of your script to appear statically in a new pane under your code, without appending to your file or opening a new one.

Click on the drop down that reads “All Languages” (by default) and scroll until you find PHP. Choose it, and then hit the Close button.

When you open a PHP script now you need only hit your cool key combination and boom – PHP results sans a web browser!

Hope this helps! Please post below with questions or suggestions.

Leave a Reply