Categories
PHP

Running Zend Framework in Shared Hosting

Since you have come to visit this post, I’d assume that you have the basics of ZF. We know that the index.php inside the “public” directory is the entry point for ZF apps. ZF also needs to find the Zend library in PHP’s include path. If we want to run our applications from the root directory, we somehow need to manage an index.php which will call the index.php inside “public” directory. We also need to upload the Zend library and put it into include_path.

1) Upload the “library” directory of Zend Framework somewhere on your hosting. Note the full path of the directory.
2) Create a project on your local machine (if you haven’t done already.)
3) Upload the project files on to your web root (www or public_html).
4) Copy the .htaccess file from the “public” directory to your web root.
5) Create a index.php and put these codes:

Replace ‘/home/masnunco/library’ with the full path to the Zend library you uploaded earlier.

Visit your website and check if it works 🙂 In most cases it would work. Have fun!

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!

Categories
PHP

Ubuntu, Zend Framework and Netbeans – Getting Started

Installation of Zend Framework is no pain in Ubuntu. They have packages for that. “zend-framework-bin” contains ZF command line tools and “libzend-framework-php” contains the Zend Library (Minimal one – I guess!). In Synaptic package manager, you will also find a transitional package – “zend-framework” and extra libraries with “libzend-framework-zendx-php” 🙂

I installed “zend-framework-bin” which also installed “libzend-framework-php” for me:

I was now ready to get started with ZF. Netbeans for PHP has built in support for Zend Framework. So I gave it a try. But I noticed, to use ZF 1.10 and over, you need to register the Netbeans Provider by clicking a button.

Tools > Options > PHP > Zend > Click “Register Provider”

In my case, I was getting error messages.

include_once(): Failed opening ‘NetBeansCommandsProvider.php’ for inclusion (include_path=’/usr/share/php/libzend-framework-php::/usr/share/php/libzend-framework-php’) in /usr/share/php/libzend-framework-php/Zend/Loader.php on line 146

After browsing the Internet for a while, I managed to find a fix.

Copy “< NetbeansDirectory >/php/zend/NetBeansCommandsProvider.php” to “/usr/share/php/libzend-framework-php/Zend”.
Restart the IDE and try to register it again. It worked for me 🙂

Now you can run the Zend commands just by right clicking on the project in Netbeans 🙂