Categories
PHP

CodeIgniter Code Completion with the Netbeans IDE for PHP

CodeIgniter is my favorite web application framework for PHP and Netbeans is the IDE I use for all sorts of web development. The latest version of Netbeans IDE (6.9) has support for both Symfony and Zend Framework. But it still has no official support for CodeIgniter. So, in the default installation, you will always miss the fantastic code completion feature of the IDE.

After Googling a while, I just learned a magic trick that can emulate this feature in Netbeans. The process is pretty simple. We feed Netbeans a php file that has a simple sample “Controller” class definition that has phpdoc specifying the necessary properties. We put this file in a place readable by the IDE but invisible or worthless for the CodeIgniter framework. The “nbproject” directory inside the project root could be a good place to put this file. What really happens is that Netbeans reads the phpdoc and offers the completion of the specified properties in any class that extends the Controller class. Hiding it from CodeIgniter helps not to mess up with the system.

This is what I did. I created a php file and named it “nb.php”. I filled this file with the following contents:

And put the file inside my nbproject directory. Now I am getting code completion in my Netbeans for CodeIgniter.

Categories
PHP

Changing Font Style in PHP Generated Image

To change the font style, you need to use different fonts. You can use the imagettftext() function to draw text on a php generated image using GD. Here’s a code snippet:

Have a look at the function’s doc on php.net to learn more. http://www.php.net/imagettftext 🙂

It’s not that hard! Put the file in the www directory of a ubuntu LAMP server and visit the url on a web browser 🙂

Categories
Python

My First Gedit Plugin

I am now using Ubuntu 10.04. In an older post of mine, I described how you can use the PHP_Beautifier tool with Gedit to code php in a fashion. But the major drawback was that a shell output used to popup every time you used the external tool. I was looking for a solution and even after a while I could not find one.

I knew Gedit supports plugins and you could write plugins in C & Python. Blessed that I know some Python, I went through the plugin API and soon realized that gedit plugin development was not much hard. I took a sample snippet, scratched and played around and finally achieved what I wanted.

I named it “Shell Hider”. All it does is to disable the entire bottom panel so that the shell output don’t stay long. In fact, the shell window will popup for a second and then hide itself. On a fast machine, you probably won’t see the popup at all!

Download it from here: http://bit.ly/cQeTMx

Enjoy!