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.


Create a free website or blog at

%d bloggers like this: