Zend Framework, just get me started, okay?
If you are looking for a quick way to get started with the Zend Framework, then you should download this file. This download has a default setup for the Zend Framework, including:
- A conventional directory structure
- A bootstrap file
- A configuration file with 2 stages: production, staging
- An error controller
- An index controller
- etc
The only thing you need to do (if you don’t have a shared version of the Zend Framework) is to download the framework, extract it, and put the library/Zend folder, into the same place in the downloadable file.
A quick and dirty test should tell you if it works: just open
http://localhost/<foldername>/document_root/
You should see “hooray application is running.” if everything went fine.
Update:
I have also made a modular starter package available. You can download it here.
More updates:
Naneau explains a modular setup in more details here.
developercast.com » Andries Seutens’ Blog: Zend Framework, just get me started, okay? said,
Wrote on June 20, 2007 @ 7:21 pm
[…] Seutens has created his own quickstart method for working with the Zend Framework and in his latest post, he shares the files. If you are […]
Geoffrey said,
Wrote on June 26, 2007 @ 3:17 pm
Hi there, and thanks for making this archive available. I have just on remark on it: could you please include a top level directory ?
andries.seutens said,
Wrote on June 26, 2007 @ 3:23 pm
Hi Geoffrey, I am not sure I understand your question properly?
The document_root folder should be the DocumentRoot which you can set in your Apache virtual hosts. The other files are one level above, because we don’t want anyone to access them.
johnpfisk said,
Wrote on June 26, 2007 @ 3:53 pm
Thanks for this. I’ve been looking for something like this for a while.
andries.seutens said,
Wrote on June 26, 2007 @ 3:56 pm
Hi johnpfisk,
Thanks for your suggestion. Honestly, I was not aware of that feature.
I’ll update the files whenever I get a chance.
Geoffrey said,
Wrote on June 26, 2007 @ 9:09 pm
I meant, when you unrar the archive, all the files are deflated in the current directory, whereas I would have expected a, say, conventional/ directory with the files in it
hope it’s more clear
steve said,
Wrote on June 27, 2007 @ 8:58 pm
hello, very useful.
unfortunately, i don’t see this able to work in a web hosting environment using IIS.
Im not able to place folders outside of the root folder due to restrictions imposed by the host.
What changes do I need to make so that the additional folders are below the root?
andries.seutens said,
Wrote on June 27, 2007 @ 9:55 pm
Hi Steven,
Unfortunately I have no experience with IIS. All I know is that the rewrite router can also be used with the IIS webserver if Isapi_Rewrite has been installed as an Isapi extension with the following rewrite rule:
The next thing you need to do then, is to take all the files in the public_html folder, and move them one level above (make sure you modify the path that points to the application.php file in your bootstrap file).
Also, make note that this opens some security vulnarabilities, so I would highly recommend you to protect other folders like “app” and “test” somehow. In apache this can simply be done with an .htaccess Deny from all.
I would appreciate it if you post your difficulties on this blog, or to the zf-mailing list. This way we can possibly enhance the documentation for IIS users.
steve said,
Wrote on July 2, 2007 @ 7:04 pm
Hi Andries,
Thank you for your advice. I have tried out your solution for apache. Will try out and find out more for IIS.
Cheers!
deegital said,
Wrote on July 3, 2007 @ 11:25 pm
thx a lot for your help in #zftalk guy, testin’ around with your modular setup now.
Samuele said,
Wrote on July 5, 2007 @ 5:05 pm
a question
how a put variable into a view
by a controller?
how use views with this setup?
Regarda, Samuele
Kay said,
Wrote on July 6, 2007 @ 11:15 am
It works, thanks so much.
This tutorial give me a good start on using ZF.
Thanks again.
bluemaex.de » Blog Archive » links for 2007-07-06 said,
Wrote on July 6, 2007 @ 10:37 pm
[…] Zend Framework, just get me started, okay? « Andries Seutens - Modern Web Development (tags: php framework zend) […]
andries.seutens said,
Wrote on July 9, 2007 @ 9:54 am
Samuele, easy: in a controller / action:
Samuele said,
Wrote on July 12, 2007 @ 3:56 pm
ops sorry
all OK Thanks
AllenAyres said,
Wrote on July 20, 2007 @ 12:08 am
Thank you for this

I am in a similar fix as steve in that most web hosts do not allow folders/files to be added above the document root. I’ve gotten it worked out a bit by adjusting the config file and where it looks for the various folders, but it sure would be nice if zend framework was a little more flexible in working on shared hosts who do not allow editing of the apache virtual host file.
andries.seutens said,
Wrote on July 20, 2007 @ 9:35 am
Dear AllenAyres,
Currently, we are brainstorming about prototyping scripts, which will create a folder layout and class skeletons for you.
You can expect this to be added sooner or later.
CK said,
Wrote on July 24, 2007 @ 2:59 pm
getting this error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
andries.seutens said,
Wrote on July 24, 2007 @ 6:53 pm
Hi, it sounds like you forgat the trailing slash?
CK said,
Wrote on July 25, 2007 @ 3:53 pm
i have given this
http://localhost/New/document_root/
Getting the error
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
andries.seutens said,
Wrote on July 25, 2007 @ 4:09 pm
Hi CK,
It is very difficult for me to tell you what exactly the error is, with so less information. Could you check your apache’s error log? More info might be available there.
David D said,
Wrote on July 27, 2007 @ 9:31 pm
Andries, thanks for the skeletons, these sure made getting started a little easier.
However, I have a question, using the modular approach, how do I include consistent headers across all modules along the lines of you conventional skeleton.
echo $this->render(’layouts/__header.phtml’);
Thanks!
andries.seutens said,
Wrote on July 31, 2007 @ 11:52 am
Hi David D,
Please refer to:
http://akrabat.com/2007/07/11/two-step-view-in-zf100/
CK said,
Wrote on August 4, 2007 @ 11:52 am
This is the error in the log file..any help?
C:/Apache2/xampp/htdocs/New/document_root/.htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration
andries.seutens said,
Wrote on August 4, 2007 @ 1:01 pm
Make sure to uncomment the following line in your .htaccess file:
And restart apache. That should work.
wirda said,
Wrote on August 6, 2007 @ 6:09 am
I have try zend framework. but i got this error :
Parse error: syntax error, unexpected T_ARRAY, expecting ‘&’ or T_VARIABLE in c:apachefriendsxamppphppearZendControllerFront.php on line 636
why?
andries.seutens said,
Wrote on August 7, 2007 @ 3:42 pm
Which version of the Zend Framework are you using? Are you certain that you are running this on a PHP-5 enabled machine?
Zend Framework Bootstrap - Introduction | Specks of Code said,
Wrote on August 10, 2007 @ 12:51 am
[…] Andries Seuten’s article ‘Just Get Me Started’ […]
Chris Peters said,
Wrote on September 8, 2007 @ 9:18 pm
Hi Andries,
Thanks so much for making this available!
I’ve been trying to set up a router that basically does this:
:controller/:action/:id1/:id2/:id3
I haven’t tested if it works in the default module, but I’ve been finding that it doesn’t work in a module I’ve added to the modules directory. Do you know what I can try?
This doesn’t seem to work in the setupRoutes method:
$router->addRoute(
‘home’,
new Zend_Controller_Router_Route(
‘:controller/:action/:id1/:id2/:id3′,
array(
‘controller’ => ‘index’,
‘action’ => ‘index’
))
);
Chris Peters said,
Wrote on September 9, 2007 @ 6:13 pm
Sorry, this was the code I was trying to run:
$router->addRoute(
'default',
new Zend_Controller_Router_Route(
':controller/:action/:id1/:id2/:id3',
array(
'controller' => 'index',
'action' => 'index'
)
)
);
Jacques Marques said,
Wrote on September 13, 2007 @ 2:19 am
Hi,
Thanks for this archive. But I have some problems with ErrorController, when I try a controller that does not exists like:
http://zftest/foo
I receive this message:
Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (foo)’ in C:Program FilesApache GroupApache2htdocszflibraryZendControllerDispatcherStandard.php:193 Stack trace: #0 C:Program FilesApache GroupApache2htdocszflibraryZendControllerFront.php(909): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:Program FilesApache GroupApache2htdocszfapplication.php(155): Zend_Controller_Front->dispatch() #2 C:Program FilesApache GroupApache2htdocszfapplication.php(47): ZfApplication->dispatch(Object(Zend_Controller_Front)) #3 C:Program FilesApache GroupApache2htdocszfdocument_rootindex.php(8): ZfApplication->bootstrap() #4 {main} thrown in C:Program FilesApache GroupApache2htdocszflibraryZendControllerDispatcherStandard.php on line 193
The error controller does not fires by the router, and if I disable the exceptions in config.ini file, I receive this message:
Fatal error: Call to a member function getMessage() on a non-object in C:Program FilesApache GroupApache2htdocszfapplication.php on line 172
Can you help me to fix this?
Thanks,
Victor said,
Wrote on September 21, 2007 @ 2:40 am
Hi Andries
This has been a great help. However I’m also getting the same error as the one above post when I try to browse to a controller that doesnt exist.
I get
Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (zero)’
Can you suggest how to solve this?
Thanks
andries.seutens said,
Wrote on September 21, 2007 @ 10:07 am
Hello,
You probably have the environment set to “staging”. When you look at the config file in the “/etc” folder, you will notice that mvc.exceptions has a value of 1. This means that exceptions will still be thrown to the browser. Set this value to “0″ or edit the document_root/index.php file and change this line:
$zfApp->setEnvironment(’staging’);
to:
$zfApp->setEnvironment(’production’);
I hope this helps.
andries.seutens said,
Wrote on September 21, 2007 @ 10:10 am
Hi,
I noticed there was an unfixed bug in the conventional setup. I have resolved the issue. So i suggest you to download the conventional setup again.
Colin Seaman said,
Wrote on December 12, 2007 @ 12:01 pm
Hi,
If you add the lines:
require_once(’Zend/Registry.php’);
// zend class loader
require_once(’Zend/Loader.php’);
// register the Zend_Loader
spl_autoload_register(array(’Zend_Loader’, ‘autoload’));
At the top of your index.php bootstrap file, you’ll never need to use require, include etc in any of your files as they’ll be automatically loaded on request.
C
Anoop said,
Wrote on December 13, 2007 @ 2:52 am
I am getting this error:
Fatal error: Trying to clone an uncloneable object of class Zend_Controller_Dispatcher_Exception in C:wampzendZendFramework-1.0.2libraryZendControllerResponseAbstract.php on line 540
Any idea why??
Anoop said,
Wrote on December 14, 2007 @ 8:36 pm
never mind, I found the solution….in PHP file make sure of following switch
zend.ze1_compatibility_mode = Off
andries.seutens said,
Wrote on December 16, 2007 @ 3:28 pm
@Colin Seaman: I am aware of that. You can even do it simpler:
require_once ‘Zend/Loader.php’;
Zend_Loader::registerAutoLoad();
rafeeq said,
Wrote on December 27, 2007 @ 6:42 am
hi Andries,
please help me..i want to redirect the page in to index page while we are typing any default entry on address bar(ex:http://localhost/tester/jkhhkkj)..i want caught all exception action that not defined in the IndexController.php page as defualt action and to redirect it into index page…please
Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (jkhhkkj)’ in C:wampwwwmysubdirzf-tutoriallibraryZendControllerDispatcherStandard.php:198 Stack trace: #0
andries.seutens said,
Wrote on December 27, 2007 @ 1:19 pm
Hi,
set throw exceptions to false on your front controller:
$frontController->throwExceptions(false);
and then in your ErrorController::errorAction() do:
$this->_redirect(’/index/index’);
or whatever action you wish to redirect to.
Good luck!
rafeeq said,
Wrote on December 28, 2007 @ 6:04 am
thank u very much….
so its working now…
actually i just started with the zend now…with one simple project..hey i want know about model.how we will create a model for many database table(more than two table)?.ten what the changes have to do in indexcontroler.php?is it possible many controller page in one project?please help me..
andries.seutens said,
Wrote on December 28, 2007 @ 11:51 pm
Hi Rafeeq,
Please refer to this article by Shahar Evron about the “m” in mvc:
http://prematureoptimization.org/blog/archives/38
Zend_Form and 2 step view demo « Andries Seutens - Modern Web Development said,
Wrote on January 6, 2008 @ 7:45 pm
[…] lot of you are waiting to finally get their hands on Zend_Form. Since my previous demo was such a success, I have decided to wrap up another demo application. This demo will show the […]
Ming Chow said,
Wrote on January 11, 2008 @ 1:27 am
Hi Andries,
I was wondering what do you use the jobs directory for?
Thanks for sharing these great template, I hope something similar will make it to the zend_build_core proposal.
andries.seutens said,
Wrote on January 11, 2008 @ 9:41 am
Hi Ming Chow,
I use the jobs directory for cron jobs :).
rafeeq said,
Wrote on January 14, 2008 @ 1:46 pm
Hi Andries,
help me please, how to use pagination of table data in zend frame work?.
and what type of modification have to done in index page and controller page..please
Natalie said,
Wrote on January 15, 2008 @ 6:21 pm
Very useful website for such a newbie like me. Thanks for your article.
ganu said,
Wrote on January 16, 2008 @ 9:12 am
wow!! all working fine.
for windows : I have commented the .htaccess and working fine. I am using wamp5.
for linux : all fine no issue.
you have made life simple. till now I was confused and now all clear.
andries.seutens said,
Wrote on January 16, 2008 @ 9:44 am
Thanks all for the positive feedback!
Jesse Peurala said,
Wrote on February 6, 2008 @ 7:53 pm
I did some modifications. In my modifications you (programmer) can set debug on or off.
if ((bool) $config->mvc->debug)
{
error_reporting(constant(’E_ALL’));
ini_set(’display_errors’, 1);
}
acido69 said,
Wrote on February 11, 2008 @ 1:30 am
Andreis Hello, I like your work
I have created a Spanish version of your utility.
trackback:
http://cuatroxl.wordpress.com/2008/02/10/esqueleto-para-empezar-una-aplicacion-modular-o-unica-con-zend-frameworkzf/
Dengi said,
Wrote on February 16, 2008 @ 12:38 pm
Hi, I am a newbie using the framework,and your module has been very help full ,my framework is now properly setup .Thanx a bunch!!!!!!!!
David’s Tech Blog » Blog Archive » Zend Framework said,
Wrote on March 1, 2008 @ 10:44 pm
[…] this part out, but most of that was me trying to get it to do variations. There are some pretty good articles about how to do this in addition to the […]
medienfuzzi said,
Wrote on March 25, 2008 @ 6:14 pm
Now, THIS module made my day! Thanks a lot!!!
Jonathan said,
Wrote on April 18, 2008 @ 5:53 am
there was a small typo that might have cause people to still have issues:
Make sure to uncomment the following line in your .htaccess file:
LoadModule rewrite_module modules/mod_rewrite.so
And restart apache. That should work.
.htaccess should be httpd.conf
william said,
Wrote on April 18, 2008 @ 11:01 pm
Thanks dude..! i have been trying for weeks to set this up.. i finally got going
kenapasih said,
Wrote on May 6, 2008 @ 2:06 pm
Hi, thanks for the article.
I’ve install modular and it’s working good. but when i open http://localhost/modular/foo/test, i got error “Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (test)’ in…” and not error about ‘missing action’ test.
I try add new file under foo/controllers called TestController.php
class Foo_TestController extends Zend_Controller_Action
{
public function indexAction()
{
echo “TEST”;
}
}
and it’s works. But im confuse, it’s the right one?
Mike D said,
Wrote on May 27, 2008 @ 1:46 am
Actually, for those who do not have access a level above public, there is a simple solution.
You need to create a folder called “includes” if one does not already exist.
Inside of the folder called includes create a folder called “Zend” (note the first letter is capped.
Upload the content of the zend “lib” folder into your Zend folder.
add this line to your htaccess file
php_value include_path “/var/usr/name/public_html/includes/”
Yours might not be (probably won’t be) the same include path, but you need to change that to whatever the server path to your includes folder should be.
You may use phpinfo(); to get that information and look for DOCUMENT_ROOT then copy the value given and add includes/ to the end.
Mike D
Jeff Dickey said,
Wrote on June 19, 2008 @ 6:55 pm
(PHP 5.2.5, Apache 2.2.8 on Mac OS X 10.5.3)
I’m getting messed up by the document_root/.htaccess file. When it is there as it was unpacked from your RARchive, entering http://localhost/~[username]/modular/document_root/ into the browser address box gives a 404. When I open a terminal window, navigate to the document_root directory, and type the command “php -q index.php”, I get the expected HTML.
If I rename or remove the .htaccess file, I can see the page as expected in the browser.
For the record, Dokuwiki and WebSVN are each installed in the same parent directory as the ‘modular’ example and both work fine; it’s not a global Apache or PHP screwup.
Any ideas/pointers would be greatly appreciated. If I don’t get progress made in the next four days, I’m going to drop the idea of using ZF for the project I’m starting and try again in a month or so, *maybe*.
—
Contents of the document_root/.htaccess file:
—
RewriteEngine on
RewriteRule !.(pdf|php|js|ico|txt|gif|jpg|png|css|rss|zip|tar.gz)$ index.php
—
Relevant lines from Apache access.log
—
::1 - - [20/Jun/2008:00:36:22 +0800] “GET /~peerless/modular/document_root/ HTTP/1.1″ 200 350
::1 - - [20/Jun/2008:00:36:22 +0800] “GET /favicon.ico HTTP/1.1″ 404 209
::1 - - [20/Jun/2008:00:36:33 +0800] “GET /~peerless/modular/document_root/ HTTP/1.1″ 404 250
::1 - - [20/Jun/2008:00:36:33 +0800] “GET /favicon.ico HTTP/1.1″ 404 209
Mandrik Smith said,
Wrote on July 7, 2008 @ 3:31 am
Great thing for ZF
I encounter this is the best resource for ZF beginner…
Thanks
LordOfHatred said,
Wrote on July 7, 2008 @ 10:02 am
i just download the files.
This guy is a geniuzzzz, i hate lengthy reading.
苗雨盛 said,
Wrote on August 14, 2008 @ 3:34 am
Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (index)’
这是什么原因造成的呢
vikas sharma said,
Wrote on September 10, 2008 @ 11:53 am
wow !
it works
Thanks a ton !
Looze Stories » Architecture modulaire avec le Zend Framework said,
Wrote on September 10, 2008 @ 6:36 pm
[…] j’ai trouvé sur le blog d’Andries Seutens un billet où il fournit son squelette de travail avec le ZF en une version structurée de manière […]
Amit Shah said,
Wrote on October 21, 2008 @ 9:12 am
How could I add favicon in my site using zend framework? IE only support favicon.ico from root folder while zend is not execute any file except index.php from the root.
I have tried to put favicon.ico files in image folder and it works in FF but not worked in IE.
baseUrl}/images/favicon.ico” type=”image/x-icon” />
Would appreciate your help.
Thanks,
Ron said,
Wrote on November 15, 2008 @ 7:07 pm
in document_root/index.php i added after the header
because in 1.6.2 this constant is not defined
BLOG THIẾT KẾ WEBSITE » Các link hữu ích cho tìm hiểu về zend framework said,
Wrote on December 31, 2008 @ 9:10 pm
[…] tìm hiểu theo hướng modular luôn, vì đa số các app đều có nhiều module cả). http://andries.systray.be/blog/2007/06/18/zend-framework-just-get-me-started-okay/ (link này có kèm cả file download các bạn có thể dùng như là application skeleton). […]
Joe said,
Wrote on March 23, 2009 @ 10:42 pm
Thanks, I was looking for something like this. I kept getting funky errors.
till's blog said,
Wrote on March 28, 2009 @ 9:35 pm
Avoiding common pitfalls with Zend_Test…Sometimes I think I’m particularly stupid when it comes to learning new things. Well, that, or maybe I’m just the only one complaining enough. ;-)I feel like I’ve wasted a great deal of time last week with basics that were nowhere to be found or r…