Skip Navigation LinksHome > Categories > Code from a Category

Introduction to the Zend Framework: Part One.

User Name: serfcompany
Name: Serf
Contact Me:
Home Page:
php,mysql,javascript,html,css. Preferable working with Zend Framework. Good know javascript. I worked with various, javascript frameworks such as(jquery, YUI3, extjs, sencha touch). [More]
Viewed Times: 1167
Add Date: 06/02/2012
This article will help you get acquainted with the basic concepts of the Zend Framework and why do we need it?


First of all, you just the same and clearly understand what, exactly is a framework?

Framework - a term that has a very vague meaning in programming is the name some simple conceptual framework that is used to solve complex problems.

Second, we need to understand what the Zend Framework and why do we need it?
Zend Framework - a high quality framework, which is a library of open source software to develop web- applications and web- services based on PHP.

It is easy to use and yet provides powerful features that allows you to build a modern, flexible and secure Web sites.
Zend Framework provides the hands of professional opportunities for building high-quality web- applications.

We turn to the case.

To get started, download the framework itself.
Akuratnenko put it to a higher level public folder in the folder «library» (assuming you have already created account as required by your local or remote server).
Let's just agree that Zend folder will be called «Zend».
As a result, you get a directory structure:

|   - library
|   | + Zend
|   |----
|   + public_html

Next, we will need somewhere to put the files of the application.
Let's call this folder «application», put the folder in the root of your site (the same place where, and «library») and immediately create it, such as catalogs:

  • «controllers» - Here lie the controllers;
  • «models» - this will be based on the model;
  • «views» - but here, view scripts;

    Why so? The fact that the framework implements a set of patterns of programming, one of which is the pattern of MVC (Model-View-Controller).

    Architecture Model-View-Controller is very effective for building large and complex projects, it clearly separates the part of software from its site design.
    Out of it with the word: the usual type of procedural programming is not so easy to use and effective, it will not allow you to maintain a cumbersome system.

    MVC Architectur??e

    After all prepared you should get the following directory structure:

     | - application
     | | + controllers
     | | + models
     | | - views
     | | + filters
     | | + helpers
     | | + scripts
     | |----
     | - library
     | | + Zend
     | |----
     | + public_html

    In the public_html directory, create a file «. Htaccess» with the following contents:

     RewriteEngine on
     RewriteRule !\.(js|ico|gif|jpg|png|css|rar|exe|txt|doc|xls|mdb|JPG|PNG|GIF)$ index.php
     ErrorDocument 404 /index.php
     ErrorDocument 403 /index.php

    These directives will cause the server to "send" all requests for the file index.php, where they will be handled by the framework.
    Files with these extensions will be given to the user directly.
    If you want some catalogs off mod_rewrite, so the server does not "send" requests, you need to put them in the file «. htaccess» with the following contents:

    RewriteEngine off

    Now create a boot file where we configure and start the Zend Framework. List the program code for the file index.php:

    Now analyze the code on the shelves. The following lines show what errors should be displayed by the interpreter and the locale specified.

    Zend Framework is targeted to ensure that its files were in the include_path, so we add the following lines to the right directories.

    Next, we connect the autoloader class Zend_Loader, which automatically connects the resulting classes.
    For an automation plug-classes should be in the include_path.
    The class that we need first of all - the primary controller.
    In his work, in turn, uses a special class of router, whose task is to find a URL for the mapping function corresponding web page.
    Then we report the primary controller kit location other controllers:


    If you now try to run our application (opening the site in a browser), then you will see an error message!
    But do not worry, we're just still not fully formed our application and will need something else to do.
    That's what I tell you the following article, which will be written soon ... At this time, I suggest you read the official leadership of Zend Framework.

Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.