MrBool
You must be logged in to give feedback. Click here to login
[Close]

You must be logged to download.

Click here to login

[Close]

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

[Close]

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

Getting started with Zend framework in PHP

The Zend Framework has become one of the most popular frameworks recently. This article will discuss this framework and its implementation.

[close]

You didn't like the quality of this content?

Would you like to comment what you didn't like?

The Zend Framework has become one of the most popular frameworks recently. You know that the PHP is an object oriented language and it has become very popular. The PHP stands at the top of the dominant languages. It was installed on most UNIX and Linux based web servers. And if you were a programmer, it was easy to get a hosting account that would let you use it. You can easily communicate it Java, J2EE, Perl languages.

Some features of Zend Framework:

  • This is based on PHP language
  • This is object oriented Language
  • Uses the MVC pattern
  • Have open source contributor

Zend is a PHP based framework. Recently, web development has become a very bloodthirsty arena for programming languages and by using the framework, user can do various kinds of activities. As a result, there has been an excess of options for programmers to choose from. Most of the time, a significant amount of time can be spent on searching for tools to speed up development instead of recreating from scratch. This writing is aimed at PHP developers who are looking to learn more about how to acquire knowledge of Zend based framework. This is not a comparative list of all PHP frameworks, as there are many new options like CakePHP and Symphony to name two. Zend framework seems to fit nicely with my requirements and it may not too long time to become familiar with this.

If we want to work with Zend Framework, this has the following requirements:

  • PHP 5.2.4 or higher version than that
  • A web based server supporting mod_rewrite or similar functionality.

I have assumed that you are running the PHP 5.2.3 or higher with the Apache web server then your Apache installation must have the mod_rewrite extension installed and configured. This time, you must also ensure that Apache is configured to support .Htaccess files.

This is normally done by changing the setting:

Listing 1: Changing settings

AllowOverride None
to
AllowOverride All
in your 
httpd.conf
Download:

If you want, you can download the zip Zend framework from any website. The Zend Framework is supplied with a new command line tool.

Zend tool for window:

  • Now create a new directory in Program Files that is called ZendFrameworkCli
  • Click on the downloaded archive file, ZendFramework-1.8.4PL1-minimal.zi
  • This time copy the bin and library folders from within the Zend Framework-1.7. 4PL1-minimal.zip
  • Folder window to the C:\Program Files\ZendFrameworkCli folder. You will get two sub folders: bin and library within it.
  • Now you add the bin to the path of:
  1. Within the Control Panel find out the System section.
  2. Choose Advanced and then press the Environment Variables button within it.
  3. In the “System variables” list and find the Path variable and double click on it. Page
  • This time adds; C:\Program Files\ZendFrameworkCli\bin to the end of the input box and press okay.

By this way you will able to configure the Zend framework on your system and able to enjoy the great feature of it.

Getting our application:

We are going to develop a normal inventory management system for displaying our CD album. The main page will list our collection and permit us to add, edit and remove CDs. We are going to store our list in a database with a very simple table schema like this:

Table Schema

Figure 1: Table Schema

Creating the project:

Now you open Terminal or Command Prompt and type and change directory to the root of your web server using the CD command prompt. You need to make ensure that you have permissions to create files in this directory and that the web server has gotten the permissions. Type:

zf create project zf-tutorial

The ZF apparatus will create a directory called zf-tutorial and populate it with the recommended directory Structure.

: Zend project file system

Figure 2: Zend project file system

The presented application/ directory is where the source code for this website stands. We have separate directories for the replica, view and controller records of our application. Here, the public/ directory is the public-facing root of the website and that means that the URL to get to the application will be http://localhost/zf-tutorial/public/. This is so that most of the application files are not accessible directly by the server and so on.

For example, you could create a virtual host called zf-tutorial.localhost that looked like that one:

Listing 2: Create virtual host

<VirtualHost *:80>
ServerName zf-tutorial.localhost
DocumentRoot /var/www/html/zf-tutorial/public
<Directory "/var/www/html/zf-tutorial/public">
AllowOverride All
</Directory>
</VirtualHost>

There are some supporting images; JavaScript and CSS files are stored inside in separate directories under the public/ directory folder. The downloaded Zend Framework files will be placed in the library/ directory. If we need to use any other libraries as per the requirement, they can also be placed here.

Copy the library/Zend/ directory from downloaded archive file (ZendFramework-1. 9.0. zip) into your self-tutoring and library/, so that your zf-tutorial/library/ contains a sub-directory called Zend/.

The Zend Framework controller uses the Front Controller design model and routes all requests through a single index.php file. This formant able to ensure that the environment is set up correctly for running the application (identified as bootstrapping). We reach this using an .Htaccess file in the zf-tutorial/public address list that is generated for us by Zend_Tool which redirect all requests to public/index.php which is also created by Zend_Tool. This is a quite easy job to change the formation of it. The index.php file is the entry point of our application and is used to create an instance of Zend_Application to initialise our application and then run it. This file also defines two constants: APPLICATION_PATH and request_ENV which define the path to the application/ directory and the environment or mode of the request. The generated .hatches file sets it to develop.

The Zend_Application starts at the beginning of the server. It starts up when the component is used to start up the application and is configured to use directives in the configuration file: application/configs/application.ini. This file is also auto-generated for us .The Bootstrap class that extends Zend_Application_Bootstrap_Bootstrap is provided in function/Boostrap.php which can be used to execute any specific startup code required.

Listing 3: Bootstrap class


<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
return $moduleLoader;
}
}
?>

By using this way we will able to run and configure the Zend framework. This framework helps us start any PHP project. Recently PHP offers object oriented facilities. That helps a lot to the programmer with vast development of the project. You know that Zend is a lightweight framework that helps a lot to integrate PHP language quite easily within it.

This is all for this article. See you next time.



My main area of specialization is Java and J2EE. I have worked on many international projects like Recorders,Websites,Crawlers etc.Also i am an Oracle Certified java professional as well as DB2 certified

What did you think of this post?

Did you like the post?

Help us to keep publishing good contents like this.

SUPPORT US

funded

remaining

[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually � in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits � in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits
[Close]
You must be logged to download.

Click here to login