Priti's Technical Corner

April 6, 2012

HelloWorld with Zend Framework 1.11.11

Install Zend Framwork on you localhost

Quick test for zf command :
C:\>zf show version
Zend Framework Version: 1.11.11

Hello World App

1. Open command prompt and type :  zf create project helloWorld


C:\>zf create project c:\www\helloWorld
Creating project at C:/www/helloWorld
Note: This command created a web project, for more information setting up your V
HOST, please see docs/README
Testing Note: PHPUnit was not found in your include_path, therefore no testing a
ctions will be created.

2. ‘zf’ command will create a standard directory structure for hello world application

3.     C:\>cd www\helloWorld
run command : zf create controller HelloWorld


Note: PHPUnit is required in order to generate controller test stubs.
Creating a controller at C:\www\helloWorld/application/controllers/HelloWorldController.php
Creating an index action method in controller HelloWorld
Creating a view script for the index action method at C:\www\helloWorld/application/views/scripts/hello-  world/index.phtml
Updating project profile ‘C:\www\helloWorld/.zfproject.xml’

HelloWorldController Content

class HelloworldController extends Zend_Controller_Action
public function init()
/* Initialize action controller here */

public function indexAction()
// action body
4.  Open C:/www/helloWorld/application/views/scripts/hello-world/index.phtml file in editor and add

<br /><br />
<div id=”view-content”>
Hurry !!! You find me Guest <br/>Welcome To the world of Zf

5. Open index.phtml in editor [C:\wamp\www\helloWorld\application\views\scripts\index] add following text

<div id=”helloWorld”>
<div id=”header-navigation”>
<a href=”<?php echo $this->url(array(‘controller’=>’HelloWorld’)) ?>”> Welcome Note</a>

And you are ready to Go !!!

Open browser type URL http://helloworld [ I have configured it in my host settings] . Page load with link
‘Welcome Note’. Click on the link and it will show you the  following message

“Hurry !!! You find me Guest
Welcome To the world of Zf”

Happy Zf exploring !!

If you have trouble with zf command OR how to do a host settings Please drop in your message. I would be happy to assist.

My vhost entries for above application is –

<VirtualHost *:80>
DocumentRoot “C:\wamp\www\helloWorld\public”
ServerName helloworld
SetEnv APPLICATION_ENV “development”

<Directory C:\wamp\www\helloWorld\public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all

ErrorLog “logs/helloworld-error.log”
CustomLog “logs/helloworld-access.log” common
I request all readers to verify that mod_rewrite is on and the vhost entries are correct. You may also find following error

Warning: require_once(Zend/Application.php) [<a href=’function.require-once’>function.require-once</a>]: failed to open stream: No such file or directory in C:\wamp\www\helloWorld\public\index.php on line 18

Fatal error: require_once() [<a href=’function.require’>function.require</a>]: Failed opening required ‘Zend/Application.php’ (include_path=’C:\wamp\www\helloWorld\library;.;C:\php\pear’) in C:\wamp\www\helloWorld\public\index.php on line 18

This error is because zf create empty application structure it do not copy Zend libraries for this either you can set the path in index OR you can copy ‘Zend’ folder  from downloaded Zend framework package in you application. In this case ‘C:\wamp\www\helloWorld\library”.

If you face Application Error please set “phpSettings.display_errors = 1” in application.ini .It will gives complete exception stack which will be helpful to resolve the error.



  1. THis is very useful for beginer in zendframe work.

    Comment by mukesh — April 12, 2012 @ 12:44 am

  2. good one prity .That ‘s really help for the beginner who want to learn zend ……like me………

    Comment by saquib — May 31, 2012 @ 1:53 pm

  3. I am attempting to get started with Zend as an MVC framework. I’ve used it in the past as a function library. I create a project and can view it. I can even add functions to the index controller and access them, but I cannot make it access a new controller. I just get a 404.

    Comment by Sorak — June 3, 2012 @ 9:27 pm

  4. thx, but it doesn’t work 😦 I get error in browswer, after click on link:

    Not Found

    The requested URL /helloWorld/public/HelloWorldi was not found on this server.

    Comment by trolll — June 4, 2012 @ 1:56 pm

  5. oh sorry, it works!

    Comment by trolll — June 4, 2012 @ 2:46 pm

  6. /helloWorld/public/ works
    but clicking the link does not it gets 404

    /helloWorld/public/index.php works
    but clicking the link works and the browser url is

    why is this happening?

    Comment by Ahmad Musa — September 4, 2012 @ 8:41 pm

  7. solved
    just the apache configs changed to allow override
    AllowOverride ALL

    for the vhost directory

    Comment by Ahmad Musa — September 4, 2012 @ 9:16 pm

  8. Would you be able to elaborate on the setup of the virtual hosts? I assume this is something in the httpd.conf file but am not exactly sure what to do.

    I changed my document root to C:www\ but I need to add use the URL localhost\helloWorld\public to access the initial page which seems to work fine and displays the link to the Welcome Note.

    When I click the link, I get the following error error. It looks like it’s added some strange characters (”/) to the path it’s looking for.

    “Not Found

    The requested URL /helloWorld/public/”/helloWorld/public/index/index/‘controller’/’HelloWorld’” was not found on this server.”

    Any idea what’s happening, how to fix it?

    Comment by Craig — November 3, 2012 @ 11:29 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Create a free website or blog at

%d bloggers like this: