Categories
PHP

Using Gedit as a PHP IDE

I’ve been using Ubuntu 9.04 as my primary OS for a while now. I love the power and flexibility of this free and open source OS. Besides PHP, I code Python mainly. I use the Netbeans IDE for PHP and the built in Gedit editor for editing all other sorts of text files and scripts. I like the simplicity and lightweight nature of this editor. Netbeans IDE is very good for web application development. Specially, I have always enjoyed the project management features for easy management of my different projects. The main reason I have been using Netbeans is the Alt+Shift+F command. The formatting option that reformats my entire page with appropriate indentation and makes it readable. Yes, it is cool! But I hate the sluggishness of Netbeans. I know, this is the fault of the slow JVM. Also, when Netbeans lose the focus and regains later, I need to right click or interact with the GUI before I can start typing. This was pissing me off. So, I started using Gedit for quick fixes and hacks. I like the font of the editor, not to mention the cool color schemes. I was wondering if there were any plugins for Gedit to format php codes like Netbeans.

No, there is no dedicated plugin for that. But Gedit has the ability to use external tools to interact with the documents. I installed the php_beautifier pear package and used it with Gedit to partially achieve what I was looking for.

1) I downloaded the PHP_Beautifier package from PHP Pear (http://pear.php.net)
2) Installed it by typing:

cd Desktop
sudo pear install PHP_Beautifier-0.1.14.tgz

The pear package installed a command line utility “php_beautifier” which lets us beautify php codes.

3) Open Gedit. Go to: Edit > Preferences. Visit the “Plugins” tab and activate the External Tools command.

4) The plugin will enable you to let external commands help you process the document. Let’s build our php beautifier for Gedit.

5) Go to: Tools > External Tools. Click “New”. Fill up the form like below:
Description: PHP Beautifier
Shortcut Key:
Commands:

php_beautifier -l "Pear()"

Input: Current Document
Output: Replace Current Document
Applicability: All documents.

You can click on the “New Tool” label to rename the tool. Let’s rename it to “PHP Beautify” and close the dialog box.

Now, we are ready to beautify our php codes from Gedit. Just type in some php codes. Go to: Tools > PHP Beautify and see the output. Please Save the document. You can’t edit the document unless you save after the processing.

PS: Please remember that, it beautifies php only. It will not be able to beautify inline html and php together. I am looking for some command line tool that can help me achieve that. And then, I will say goodbye to Netbeans and stick to Gedit 🙂

7 replies on “Using Gedit as a PHP IDE”

I use netbeans too and have been looking for this functionality within gedit on and off for some time.
Thanks for posting.

masnun: Thanks for the post!
Lenin: Thanks for the tip on geany! I have installed it and really like the interface.

Cheers!

Shows me some errors:
“PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 650”

So, my PHP version can’t work with it?
PHP/5.3.5

Comments are closed.