Zend Framework Courses-Introduction

Hello everyone, I am here with Zend Framework tutorials.In this series, i will try to tell you about Zend Framework by using my experiences.Zend Framework will be discussed on Linux(Ubuntu).

Before starting the tutorial i want to make an important reminder.I would recommend you to practise examples at the end of each subject, the more you practise, the easier you understand.
In this tutorial, i will tell you about Zend Framework installation and i will give you an example at the end.

What is Zend Framework?
Zend Framework is a library written in PHP that contains several components. Nowadays, it is widely used on web applications.

Prerequisites:

  1. PHP 5.x
  2. Apache(Lighttpd, or any other web server software)
  3. Zend Framework

Installation:

  1. Download the latest version of Zend Framework from here.
  2. After download, copy the Zend Framework folder to somewhere you want. We will assume”/opt/” folder in this example.

<br />
/opt/Zend/<br />

We will create project by using Zend Framework CLI(Command Line Interface). In order to use CLI, there must be a command that linked to “/opt/Zen/bin/zf.sh” shell script.For this, please run below command.

<br />
ln -s /opt/home/zend/bin/zf.sh /opt/home/bin/zf<br />

You must get the version of current version of installed Zend Framework when you execute the command “zf — version”.If it is OK, it means you have successfully installed Zend Framework

Creating Project:

Inorder to create project, please execute below command in command line.

<br />
zf create project zfproject<br />

We have a new project now! This project has only the folder structure that Zend specified.In order to use Zend Framework, we must let our project know about Zend library.We have two ways for this.

  1. Copy the “Zend” folder exists under library folder in downloaded Zend Framework folder to library folder in our zfproject.After copy operation, you can use all of the Zend components
  2. Open up the “php.ini”.If you don’t know where the “php.ini” is, you can find it by executing this command in command line “php — ini”.My php.ini files are in /etc/php5/cli/ and /etc/php5/cgi/ and i will edit both of them.Find the word “include_path” in the file and update its value as “/opt/Zend/libary” .By doing this, you can use Zend library for all the projects that exist on your system.

Creating virtual host:

In order to make your project work on the browser, you must create a virtual host record for your project.I am using Lighttpd for web server application and my virtual host folder is “/etc/lighttpd/sites-enabled”.I create a file called “zfproject.conf” and make its content like below:

<br />
$HTTP[&quot;host&quot;] =~ &quot;fd&quot; {<br />
server.document-root = &quot;/home/huseyin/workspace/zfproject/public&quot;<br />
accesslog.filename = &quot;/var/logs/zfproject.access.log&quot;<br />
setenv.add-environment = (&quot;ZF_ENV&quot; =&gt; &quot;locallinux&quot;,<br />
&quot;ZF_INST&quot; =&gt; &quot;zfpoject&quot;)<br />
}<br />

An important point here is, server.document.root value must be the “public” folder of our project.

Restart the web server after virtual host creation.After that, open up “/etc/hosts” file and add the host entry next to “127.0.0.1”.You can view the project on browser by doing this.

If you can see the sample Zend Framerwork page on the browser after enter the url “zfproject”, it means that everything is OK.

That’s all for installation, If you have any question, please do not hesitate to ask here. I will be answer the questions as soon as possible.

See you on next tutorial…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s