In one of our earlier posts we have told you how to install the PHP based Zend application Framework on Ubuntu. But in that post we just showed you how to install
the framework. In this article we will tell you how you can get started
with developing your projects in the Zend PHP framework using Ubuntu.
After you you have installed Zend on your Ubuntu machine using apt-get, you can find the installed Zend client library files at this location:
Zend has a nice command line based tool called the zf or zf.sh using which you can create new projects and add views and controllers to your projects. The best part about these command line tools are that they reduce your code writing by creating all the required project files and populating these files with the bare minimum code snippets!
For eg, if you want your Zend project (which is for instance named - myproject) to reside in the /var/www/myproject folder then navigate to the /var/www folder and issue this command from the command prompt:
The entry point for your new Zend project is from the index.php file which is located in the /var/www/myproject/public folder.
You will be now able to access your new project at this url (provided you are using your default hosts and apache configurations):
After you you have installed Zend on your Ubuntu machine using apt-get, you can find the installed Zend client library files at this location:
/usr/share/php/libzend-framework-php/
The total directory size is a meager 32 MB, so you should not worry
about this. Now that we know where the library files are, lets get
started with creating our first Zend project in Ubuntu.Zend has a nice command line based tool called the zf or zf.sh using which you can create new projects and add views and controllers to your projects. The best part about these command line tools are that they reduce your code writing by creating all the required project files and populating these files with the bare minimum code snippets!
For eg, if you want your Zend project (which is for instance named - myproject) to reside in the /var/www/myproject folder then navigate to the /var/www folder and issue this command from the command prompt:
zf create project myprojector
zf.sh create project myprojectYou can now see that five new directories - application, docs, library, public, tests have been created inside the /var/www/myproject folder. These folders contain some files - controllers, layouts etc about which we will tell you in another post.
The entry point for your new Zend project is from the index.php file which is located in the /var/www/myproject/public folder.
You will be now able to access your new project at this url (provided you are using your default hosts and apache configurations):
http://localhost/myproject/public/However at this moment, if you access the project URL mentioned above, you may see an error. There is one last thing we need to do in order to fix it and get started. Open the index.php file located inside the /var/www/myproject/public folder and paste the following code snippet just above the line that says - /** Zend_Application */
set_include_path(get_include_path().PATH_SEPARATOR.'/usr/share/php/libzend-framework-php');
The above code snippet tells our app the exact location of the Zend
libraries which we just installed. Now, if you reload the page, you can
see the Zend Welcome page. We will tell you how to remove this welcome
page in our next Zend for Ubuntu tutorial.