First application in 3 steps | first zend framework application

Follow the below steps and i assured you will got succeed for your first zend framework application.

Step 1 - Install zend framework :-
There are two ways to do this -
(a) Install zend server - Zend Server has native installers for Mac OSX, Windows, Fedora Core, and Ubuntu, as well as a universal installation package compatible with most Linux distributions.

After you have installed Zend Server, the Framework files may be found under /usr/local/zend/share/ZendFramework on Mac OSX and Linux, and C:\Program Files\Zend\ZendServer\share\ZendFramework on Windows. The include_path will already be configured .

to include Zend Framework.

(b) If  you do not wants to install zend server then you can download zend library form Zend library latest   and extract it where you wants in your PC.

Unpack the whole framework under a folder and add that folder/bin to you path.

So zend framework is installed on your computer now.

Test it on terminal (in Windows, Start -> Run, and then use cmd), type zf and press enter it should not show " 'zf' is not recognized as an interanl or external commnad, operable program or batch file."


If you got above error on your console then check you environment variable and add unpacked zend folder/bin to path variable now restart the console again and this error will not be longer visible.

Now you are ready for step two.


Step 2 - Create your project :-

Open a terminal (in Windows, Start -> Run, and then use cmd). Navigate to a directory where you would like to create a project. Then, use the path to the appropriate script, and execute following command:

"zf create project myproject"

after execution this command will create a folder myproject which structured like -

 
     myproject

      |-- .zfproject.xml
  
      |-- application
  
          |-- Bootstrap.php
 
          |-- configs
  
              |-- application.ini
 
          |-- controllers
 
              |-- ErrorController.php
  
              |-- IndexController.php
  
          |-- models
 
          |-- views
 
              |-- helpers
 
              |-- scripts
 
                  |-- error
 
                     |-- error.phtml
 
                  |-- index

                      |-- index.phtml
 
      |-- library
 
      |-- public

          |-- .htaccess
 
          |-- index.php
 
      |-- tests

          |-- application
 
              |-- bootstrap.php
 
          |-- library

              |-- bootstrap.php

          |-- phpunit.xml

      |-- public

          |-- .htaccess

Step two is done, check your peoject path and its structure.

Step 3 - Create a virtual host :-

(We are using Apache web server(http://httpd.apache.org/) for this example.)

To create your vhost, you need to know the location of your httpd.conf file, and potentially where other configuration files are located.

      C:\Program Files\Zend\Apache2\conf (Zend Server on Windows machines)

Define a virtual host in httpd.conf, you can use following reference if famalier with apache and php or just copy below

lines in httpd.conf

 
     <VirtualHost *:8181>

             ServerName localhost

             DocumentRoot "/path/to/myproject/public"       

           SetEnv APPLICATION_ENV "development"

             <Directory "/path/to/myproject/public">

                DirectoryIndex index.php

                AllowOverride All

                Order allow,deny

                Allow from all

           </Directory>

</VirtualHost>

- replace /path/to/ with your created myproject path

- Don't forget to add Listen 8181 in httpd.conf

- Rewrite module should enabled in httpd.conf.

- DocumentRoot setting specifies the public subdirectory of our project; this means that only files under that directory can ever be served directly by the server.

- AllowOverride, Order, and Allow directives; these are to allow us to use htacess files within our project.

- The SetEnv directive. What we are doing here is setting an environment variable for your virtual host; this variable will be picked up in the index.php and used to set the APPLICATION_ENV constant for our Zend Framework application. In production, you can omit this directive (in which case it will default to the value "production") or set it explicitly to "production".

Start your webserver (or restart it), and you should be ready to go.

Type http://localhost:8181/ on your browser and if everthing is gone fine you will got zend welcome page.

If you got issue "....(Zend/Application.php) [function.require-once]: failed to open stream...." then put the Zend folder (within you downloaded \ZendFramework-version-blah\library\ ) right in the application directory you are using with (looks like it is \path\to\myproject\lirary).

Hope it well helpful for all Zend framework beginners.

    

19 comments:

  1. Hi author,
    It's a nice attempt, expect a Hello world application which use any zend library from your part soon.

    Regards
    Anes

    ReplyDelete
    Replies
    1. thanks for sharing nice post. we are coupon base website sharing huge collection of shopping coupon like InkFruit Coupon

      Delete
  2. Hi amskape,
    Thanks for your valuable comments.

    Any new body can also convert this application into zend's "Hello world" application.

    Actually Zend create home page for us, when we using command line tool for create a new project.

    If you wants to change this application as an Hello world application, then go to /path/to/myproject/application/views/scripts/index and replace the content of index.phtml with "Your content". Now it becomes a simple Hello world application.

    ReplyDelete
  3. Thanks a lot for the useful tips on Zend framework. I encourage you to write more useful posts on Zend.

    ReplyDelete
  4. Zend is totally mess yaar. I want to learn MVC. I am amateur never have worked much on a core Object Oriented PHP. and bla bla bla...

    ReplyDelete
  5. Thanks to you I solved error 403 :)

    Zend tutorials are weak (IMO), but Zend/Symfony is a must, at least where I live.

    ReplyDelete
  6. After checking several tutorials (including the official, the one from IBM and this) I am truly disappointed with Zend Framework. I think it is nearly impossible to install this framework, at least on Mac OS.

    ReplyDelete
    Replies
    1. Can you post what problem you are facing? So we can help you

      Delete
  7. It is just copy paste nothing else,people...

    ReplyDelete
    Replies
    1. Sorry, if i hurt your feelings but i did only simple the things. As Zend documentation is tough to understood for newbie. I tried here to explain their code in my language.

      Delete
  8. no me also face trouble for install still am not getting any one can helpme

    ReplyDelete
    Replies
    1. Its better to specify problem what you are facing, so visitors can help you

      Delete
  9. The framework is so sloppy that it's difficult to describe just a single problem in isolation. It's far from clear what any file or component of the framework does, or how/if it interacts with other files or components. Installation and setup worked for me, but now I have all this spaghetti all over my hard drive and the interdependencies within the framework are nowhere described. What a nightmare.

    ReplyDelete
    Replies
    1. Learning with basic steps surely clear you till the end of ZEND.

      Delete
  10. i am also facing problem to install, can anyone refer me any video for installation

    ReplyDelete
  11. Better option is do it on xampp, and great enviroment for editing, and creating zend projects is zend studio

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. hello, I m not abe to how create view folder & not able to how create index file in zend framwork. please anyone may help me.

    ReplyDelete
  14. Zend is an object oriented open-source software framework for building high quality Web Application speeds up the production and improves end user satisfaction. It can help the PHP developers to speed up the development and complete large development projects faster.

    Web development company in India | Managing Virtual Teams

    ReplyDelete