Categories
PHP

Ubuntu, Zend Framework and Netbeans: Setting Up VirtualHost and Code Auto Completion

If you follow the Zend Framework tutorial here: http://framework.zend.com/manual/en/learning.quickstart.create-project.html, you would probably do the same thing they did – creating a ServerName and then editing the “/etc/hosts” file. Thats the way, you should do in the production server. But in your local development environment, you can skip messing up with the “/etc/hosts” file by running the Zend virtualhost in a different port.

Here’s my VirtualHost for Zend Framework that runs on port 8080:

Restart your apache :

Visit : http://localhost:8080 😀

Now, we can configure Netbeans to open this URL whenever we click the green play button (Run Project) or hit F6.

Go to: File > Project Properties > Run Configuration
Put the URL http://localhost:8080/ in the Project URL field.
NB: Don’t miss the trailing slash or it won’t work 🙂

Ok, now that we have Zend Framework up and running, lets add code completion to Netbeans. Even if you add the Zend tools in Netbeans (as described in my last post), it won’t add the Zend Library into it’s inspection scope. So, it will fail to offer you any code completion. We can add the Zend Framework library to the project include path to enable code completion.

Go to: File > Project Properties > PHP Include Path
Click “Add Folder” and put the path to your Zend Library 🙂
In my setup the path is: /usr/share/php/libzend-framework-php
It would be the same for you if you also installed ZF from Ubuntu repository 🙂

Restart the IDE and have fun!