Tutorial: Getting Started with Zend Framework 1.8

This tutorial is intended to give an introduction to using Zend Framework to write a simple database driven application. It has been extensively rewritten for version 1.8 of the framework and takes full advantage of the Zend_Tool command line script and Zend_Application for bootstrapping. Other components used include Zend_Controller, Zend_View, Zend_Db_Table and Zend_Form.
This tutorial has been tested on version 1.8 of Zend Framework. It will not work on any version prior to version 1.8.
If you are deploying to a "user" site (e.g. http://localhost/~rob), then change the RewriteBase line in your .htaccess file should be: RewriteBase /~rob/zf-tutorial/public/.
English version: Dowload the PDF (v1.6.2).
Code
The associated code is available:
- Zip file of tutorial (~9KB)
- Zip file of tutorial including ZF 1.8.0 (~2.3MB)
- My Subversion repository
Further reading
Once you have finished this tutorial, consider buying my book, Zend Framework in Action. Also, the Quick Start is worth reading.
Previous versions of this tutorial
The tutorial for Zend Framework 1.5, 1,6 and 1,7 is still available, along with the translations for it. You can also find original tutorial for Zend Framework 1.0.
Changelog
- 1.6.2
- Code in deleteAction() now matches code in zip file! Thanks to Luis and Oleg Lobach.
- 1.6.1
- Minor fixes. Thanks to Tomas Fejfar and Luis.
- 1.6.0
- Completely updated and significant portions revised for Zend Framework 1.8

May 1st, 2009 at 11:39 #
[...] Click here for the full details » [...]
May 1st, 2009 at 12:50 #
Hi,
I've finished reading the tutorial. Easy to follow but still touching a lot of required and important areas of the ZF.
Good stuff to get started!
May 1st, 2009 at 15:08 #
Great article, I'm starting a new project and I'll use the ZF 1.8.
May 1st, 2009 at 15:22 #
[...] Najlepszą drogą do zapoznania się z nowymi narzędzami może być oficjalny przewodnik Zend Framework Quick Start, a także przewodnik Roba Allena. [...]
May 1st, 2009 at 15:49 #
[...] You can find out more about new RAD features reading Zend Framework Quick Start and Zend Framework Tutorial by Rob Allen. [...]
May 1st, 2009 at 22:24 #
Thanks for great tutorial and operational changes for ZF1.8 release.
But in delete action something strange - why you use $form variable and where it initialized?
May 2nd, 2009 at 08:08 #
Oleg,
Fixed in version 1.6.2.
Regards,
Rob...
May 3rd, 2009 at 00:22 #
[...] Akrabat hat auch schon sein Tutorial auf 1.8 angepasst. Author: KingCrunch Categories: PHP, Zend Framework Tags: Kommentare [...]
May 3rd, 2009 at 19:04 #
Nice tutorial, but one thing I'm not clear on is how to use my own configuration variables in the application.ini and access them?
For example, in earlier ZF versions, I could put a custom setting in app.ini:
cms.max.feeds = 10
Then in the bootstrap:
$configuration = new Zend_Config_Ini(
APPLICATION_PATH . '/config/app.ini',
APPLICATION_ENVIRONMENT
);
$registry = Zend_Registry::getInstance();
$registry->configuration = $configuration;
The in the controller this worked:
$this->_nMaxFeeds = INTVAL(Zend_Registry::getInstance()
->configuration
->cms
->max
->feeds);
but now I have no idea to get the same functionality in ZF 1.8.0.
I tried following your tutorial, the Quickstart, reading the ZF docs and reading through a good chunk of the code and am stuck.
Thanks.
May 3rd, 2009 at 19:55 #
Joe,
In a controller method, you can do this:
If you want it as a Zend_Config object, then add this line:
Regards,
Rob...
May 3rd, 2009 at 20:18 #
Aaah. Thank you so much!
May 4th, 2009 at 04:20 #
Am I just stupid or did I miss something. I set up the tool and tried to get the scaffolding to come up. it can't seem to include Application.php, and I know that is there.
Failed opening required 'Zend/Application.php' (include_path='/var/www/zf-tut/library:.:/usr/share/php:/usr/share/pear' in /var/www/zf-tut/public/index.php on line 18
but look:
/var/www/zf-tut/library/Zend$ ls -al Application.php
-rw-rw-r-- 1 colleen colleen 9232 2009-05-03 20:31 Application.php
May 4th, 2009 at 04:26 #
I got it to work by deepsixing the symlink to the Zend library and actually copying it. It would be nice to know why the symlink didn't work. It has always worked in my other ZF experiments.
May 4th, 2009 at 09:42 #
Hi!
While working with previous releases of ZF, I was always setting the baseUrl via FrontController:
$frontController->setBaseUrl('/some/path');
How to set this path now?
Also, I am using .htaccess file to start my app, in root directory:
RewriteRule .* public/index.php
But using it now (I am not using VirtualHost to set the path to public dir) makes ZF display 'Page not found' error.
How do I solve this?
Regards,
Jacek
May 4th, 2009 at 10:15 #
Again it is necessary to alter all :(. Thanks for your work!
May 4th, 2009 at 11:56 #
OK - I've solved it :)
I've just added a line of code in application.ini file:
resources.frontController.baseUrl = "/some/path"
Regards,
Jacek
May 4th, 2009 at 21:14 #
Thanks it all works. Like the new auto tools, hope they include a default layout or option therefore, now must go read the help. :)
May 4th, 2009 at 21:53 #
OK now I am very confused how I adapt stuff written w/ earlier Zend to 1.8 For example, I have this line
$frontController->registerPlugin(new Custom_Controller_Plugin_MemcachedSetup(),96);
in an old bootstrap file in the runApp method. Where do I put it now? And are we still stuck with those stupid ordering numbers? Because I think they are kludgy.
May 4th, 2009 at 23:05 #
Why is $bootstrap = $this->getInvokeArg('bootstrap');
only available in a controller method?
Config data is needed all over the place.
I'm converting my code to 1.8.0 and for example need to access the config variables in a controller action helper, but it returns "Fatal error: Call to undefined method Zend_Controller_Action_Helper_MyHelper::getInvokeArg()"
May 5th, 2009 at 01:52 #
[...] task today was to make Rob Allen's Zend framework tutorial project run on Windows. Some years ago such task could have been a problem, but as you will see, [...]
May 5th, 2009 at 05:49 #
Joe,
From a controller action, can't you just use $this->getController()->getInvokeArg('bootstrap') ?
If you really need config everywhere, then you could do this:
The config file will now be in the registry as a Zend_Config object.
Regards,
Rob...
May 5th, 2009 at 05:54 #
Thanks Rob. I've rewritten my code to circumvent it but it's very useful being able to put it all in the registry just in case.
May 5th, 2009 at 06:33 #
[...] The PDF can be downloaded here directly. And you can find some notes from his blog post here. [...]
May 5th, 2009 at 13:32 #
[...] Zend Developer Blog. Zmianie uległy także Zend Framework QuickStart oraz świetny tutorial Roba Allana (Akra's DevNotes). Author: Paweł Wojciechowski Categories: Zend Framework Tags: Zend Framework Komentarze [...]
May 5th, 2009 at 19:40 #
I understand that stuff written with the old bootstrap way will work just fine but I want to convert a small project to the 1.8 way so I can LEARN what the correspondences are. All I've seen so far is small examples of the new way without much bootstrapping. Could we have a concise point by point comparison for example: how and WHERE do you register plugins & helpers first the old way then the new way. What do these _init* things correspond to if anything in the old way. I need EXACTLY everything spelled out. just giving me code snippets won't work because I will have no idea where it goes. I think I understand they can now be resources in some way and you put them in the config yes? ??? But I am just not putting together all the pieces. I have asked questions and people give me hand wavy answers as if I already should KNOW. But I don't KNOW and I want to learn but I can't learn if I just hear glib instructions like "oh just put it in the config." What exactly is "IT" and what does the config look like and then once I do that how and where do I use it! How I learn is pretty much strictly by example. I do not understand verbal explanations very well. Is there a new ZFiA with all this in it and can I download it?
May 6th, 2009 at 23:16 #
Rob,
"If you really need config everywhere, then you could do this:
class Bootstrap extends Zend_Application_Bootstrap_Base
{
"
I don't see that file and running it returns:
"Fatal error: Class 'Zend_Application_Bootstrap_Base' not found in C:\joedevon\workspace\application\Bootstrap.php on line 2"
===
In any event, where it's disturbing me is I'd like to write my own queries rather than rely on Zend_Db_Table.
But since the getInvokeArg('bootstrap') is unavailable in the models, how are you supposed to use the vars that were brought into the Bootstrap from application.ini?
May 7th, 2009 at 05:32 #
Doh,
I meant Zend_Application_Bootstrap_Bootstrap rather. I've corrected the above example too.
It rather depends on how your model depends on your database adapter. If you use Zend_Registry, then you could do:
Regards,
Rob...
May 7th, 2009 at 05:51 #
Thank you thank you. It was making me crazy. That fixed my problems :) Hopefully I'll be good to go from here on out :)
May 8th, 2009 at 21:26 #
Colleen,
If you need to register new plugins add the following lines to your bootstrap file. I know others will be looking for the same solution.
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// ADD THESE 2 LINES
$bootstrap = $application->getBootstrap();
$bootstrap->registerPluginResource(new My_Plugin_Class());
$application->bootstrap()
->run();
May 10th, 2009 at 16:00 #
[...] set up an empty Zend Framework project: you can use the Zend Studio for Eclipse wizard or the new Zend_Tool command line. Use Zend Studio wizard to create an empty Zend Framewrok [...]
May 11th, 2009 at 17:34 #
Im new to zend framework and I have been able to follow through with the tutorial but I get the following error at the end it:
Message: No adapter found for Model_DbTable_Customers
Stack trace:
#0 E:\sites\metersys\library\Zend\Db\Table\Abstract.php(652): Zend_Db_Table_Abstract->_setupDatabaseAdapter()
#1 E:\sites\metersys\library\Zend\Db\Table\Abstract.php(286): Zend_Db_Table_Abstract->_setup()
#2 E:\sites\metersys\application\controllers\IndexController.php(17): Zend_Db_Table_Abstract->__construct()
#3 E:\sites\metersys\library\Zend\Controller\Action.php(512): IndexController->indexAction()
#4 E:\sites\metersys\library\Zend\Controller\Dispatcher\Standard.php(288): Zend_Controller_Action->dispatch('indexAction')
#5 E:\sites\metersys\library\Zend\Controller\Front.php(936): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#6 E:\sites\metersys\library\Zend\Application\Bootstrap\Bootstrap.php(77): Zend_Controller_Front->dispatch()
#7 E:\sites\metersys\library\Zend\Application.php(303): Zend_Application_Bootstrap_Bootstrap->run()
#8 E:\sites\metersys\public\index.php(26): Zend_Application->run()
#9 {main}
Request Parameters:
array(3) {
["controller"]=>
string(5) "index"
["action"]=>
string(5) "index"
["module"]=>
string(7) "default"
}
May 11th, 2009 at 17:42 #
I am using zend server 4.0.1 with apache on vista and oracle.
Thanks.
May 11th, 2009 at 19:47 #
This is a fantastic tutorial. It gives you that extra bit of understanding compared to the Quickstart. Im very new to ZF and I am eager to learn more. I'm wondering if there will be another tutorial that makes use of authentication and some kind of administration module (i.e a blog?). You've done a great piece of work here though! Two thumbs up!
May 12th, 2009 at 06:03 #
zig2na,
What is in your config file?
Regards,
Rob...
May 12th, 2009 at 13:17 #
Rob,
Thanks for your quick response. Fortunately, I have been able to resolve it.
I was using the following db strings:
database.db.adapter = Pdo_Oci
database.db.params.host = 192.168.1.10
database.db.params.username = avrladmin
database.db.params.password = nasa
database.db.params.dbname = mavrl
database.db.params.port = 1522
instead of:
resources.db.adapter = Pdo_Oci
resources.db.params.host = 192.168.1.10
resources.db.params.username = avrladmin
resources.db.params.password = nasa
resources.db.params.dbname = mavrl
resources.db.params.port = 1522
I copied it from one of my trials.
Cheers!
May 12th, 2009 at 20:29 #
Has anyone figured out how to separate controllers within the Boostrapper in ZF 1.8?
I have this in 1.7:
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory(array(
'admin' => '../application/admin/controllers',
'default' => '../application/default/controllers'
)
);
I know I can create an "AdminController" in my "top level" directory that contains all of the admin tools but that would get quite large with several actions.
This way administrative tools can be kept separate from the public side of the site (in "default"). Has anyone solved this issue?
Thanks in advance.
May 12th, 2009 at 20:37 #
Hi
I have an error
my ini file looks like
resources.db.adapter = Pdo_Oci
resources.db.params.host = localhost
resources.db.params.username = dd
resources.db.params.password = dd
resources.db.params.dbname = xe
My Albums
An error occurred
message ?>
Exception information:
Message: exception->getMessage() ?>
Stack trace:
exception->getTraceAsString() ?>
Request Parameters:
request->getParams()) ?>
May 13th, 2009 at 07:25 #
Try this with oracle adapter and note the dbname line.
resources.db.adapter = oracle
resources.db.params.host = 127.0.0.1
resources.db.params.dbname = 127.0.0.1/xe
resources.db.params.username = crm
resources.db.params.password = crm
resources.db.params.port = 1521
May 13th, 2009 at 07:43 #
Keith,
I use a separate module for administration controllers.
Regards,
Rob...
May 13th, 2009 at 12:42 #
Thanks for the great tutorial!
Can the config.ini be used to specify multiple databases? My application uses 2 DBs and it doesn't appear the DB resource can handle multiple databases specified in the ini in any way shape or form.
I know I can create a new "DBs" resource and have that handle an array of db resources, but is that the best practice?
May 13th, 2009 at 13:27 #
zig2na,
thanks for your advice. I' ll try .
If is the table in different schema. What is change in config.ini file?
May 13th, 2009 at 18:22 #
racmo,
XE uses your username to select schema provided all the other details given are correct and its able to talk to the XE listner.
May 13th, 2009 at 18:48 #
zig2na,
actually apache connect to database I saw entris in the listener.log. But the error stil goes on.
my other question is
if table's owner different schema from my provided username, how can i select the table? thanks.
best regards.
May 13th, 2009 at 20:57 #
ramco,
your username serves as your schema in XE. But you have to use 'localhost/xe' in your connect as the dbname instead of your actual username which doubles as the schema.
May 14th, 2009 at 00:06 #
[...] load models Hi there, I'm trying to follow the tutorial in Akra's DevNotes Tutorial: Getting Started with Zend Framework 1.8 but with little sucess! When I get to part that I need to add the code: public function [...]
May 14th, 2009 at 21:11 #
Hi, My problem is all identifier is in "" . oracle support uppercase identifier by default. So, how can implement CASE_FOLDING option in ini file to use db connection? is any suggestion. thanks.
May 15th, 2009 at 01:50 #
Hi,
It's really a nice tutorial. I am doing something wrong in setting up the path.
I have successfully set a path and created a project using command
zf create project xyz
Now, i need to setup actions in controllers:
According to tutorial i can do it by using command:
zf create action add index
but to do this i should be in xyz/application or xyz directory (not sure ). When i go in directory through command prompt and write the command it gives error that
"PHP.exe is not recognized as internal or external command"
And definitely it is correct because php.exe is in c:\php folder instead of c:\php\xyz folder
Can anybody tell me how can i set actions in C:\php\beta\application\controllers\IndexControlle r.php
I will really be very thankful to you.
Regards,
Umair
May 16th, 2009 at 23:13 #
Hi Rob,
Very nice tutorial! I'll definitely checkout your book.
FYI, the latest version of the pdf (v1.6.2) is missing a section at the top of page 6.
The previous version of the pdf (v1.5.2) had the following segment (before the sentence fragment) at the top of page 6:
By default, Zend Framework’s controller reserves a special action called index as a default
action. That is, for a URL such as http://localhost/zf-tutorial/public/news/
the index action within the news controller will be executed. There is also a default controller
name should none be supplied. It should come as no surprise
May 17th, 2009 at 08:41 #
ramco,
Try this:
resources.params.options.caseFolding = caselower
May 19th, 2009 at 10:26 #
hello,
Great tutotrial! It all works and the explanations are very good.
My only question is why did you get the view from the layout:
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
as directly getting the view as they show on the zends quick start guide?
$this->bootstrap('view');
$view = $this->getResource('view');
Does it have some benefit?
thanks!
Luciano
May 19th, 2009 at 10:49 #
Thanks Rob for the tutorial and answers and everyone for your comments. I learned a lot just reading the comments section. I didn't even know ZF has changed since 1.8. I like to use best practices when coding. So it was confusing to see all the differing examples and ways of doing things. Now off to read more.
Cheers!
May 19th, 2009 at 11:03 #
Luciano,
In my tutorial, I don't create a view resource within the bootstrap class or application.ini file.
Given that you can collect the view from the layout, and I needed to bootstrap the layout anyway, it made sense to grab the view that way.
Regards,
Rob...
May 19th, 2009 at 21:29 #
Hi Rob and thanks for the tutorial.
I'm having a problem, just added the actions for the IndexController.php via terminal console fine, but when I try to test the URL of the action.. example:
http://localhost/zf-tutorial/public/index/edit
I'm getting a 404 Error from Apache, I've been trying to figure out what's going on but I couldn't, a little of help would be appreciated :)
Thanks in advance!
May 19th, 2009 at 22:14 #
Ok it's solved
I just forgot to add AllowOverride All in the httpd.conf for the directory of my project, all is working fine now :-)
May 20th, 2009 at 20:54 #
Zigna,
thanks for your advice.
I used this params
db.params.options.autoQuoteIdentifiers = 0
It solves one of my problem. But this case, ID column is must be uppercase (ID). But in the sample code the identifier written by lowercase (id), I tried your advice but column identifiers still return with uppercase.
May 21st, 2009 at 00:36 #
I am newbie to Zend framework, while trying your code i got the below error, please guide
Fatal error: Class 'Models_DbTable_Albums' not found in /var/www/zend_site/application/controllers/IndexController.php on line
May 22nd, 2009 at 12:53 #
Thanks Rob for the tutorial and answers and everyone's comments.But I want to know how We can run Project with "http://localhost/myname" without typing public folder.
May 22nd, 2009 at 19:27 #
Hi Rob, guys,
I am kind of new to ZF, but keen to learn it. So i grabbed the tutorial and ZF 1.8.1 and tried the tutorial both on Win and Ubuntu servers. So I have to say I had very strange and frustrating initial results. On windows i had no bootstrap.php(lower case) file at all and noting in index.php but require_once "bootstrap.php", and as nothing in the tutorial mentioned that something should be done about that I assumed it is ok. It wasn't. Anyway downloading the code and comparing to what I have I understood that I am way off. By pasting the missing bootstrap content everything came to place. On contrary on Ubuntu Zend_Tool created a lot of bootstraping and a default module, all different again from what is used in the tutorial. I am sure that with some adaptation the tutorial will work just fine with the default configuration from Zend_Tool but for a newbie like me it is quite a struggle to get up and running without a clue that something should be changed in the default settings. Other then that it is a great introduction to ZF, and I will probably by the second edition of ZFiA since I heard that there are some errors there too still.
May 23rd, 2009 at 13:31 #
Edit to my previous comment - it seems that the problem is not in Zend_Tool, but zend studio which i desided to use for the tutorial, when you make a zf project in zs it overwrites a lot of stuff in your project structure.
May 25th, 2009 at 19:46 #
Petar,
You would need to setup a virtual host within apache (don't know if you are using apache). Search online. there are plenty of good resources for it.
May 25th, 2009 at 19:47 #
sorry previous post was meant for khem raj not Petar.
May 26th, 2009 at 13:32 #
Hi,
I want to solve this problem without using Virtual Host Please Help me.
May 26th, 2009 at 14:53 #
KhemRaj,
Place your index.php file in the root directory and modify paths appropriately.
Regards,
Rob...
May 26th, 2009 at 19:58 #
Hi Rob,
I found a syntax error - bottom of page 3, DocumentRoot must be '/var/www/html/zf-tutorial/public', but in manual '/var/www/html/z-ftutorial/public'
With best regards...
May 27th, 2009 at 05:58 #
Thanks Oleg :)
Rob...
May 27th, 2009 at 07:09 #
hi,
Thanks for reply Please tell me how we can set the appropriate path after placing index.php in root please explian in detail.
Thanks.
May 27th, 2009 at 13:18 #
Hey,
I'm trying to do your tutorial 'Getting started with Zend Framework' Document Revision 1.6.2 and I've come to page 13 of 17. When trying to view the index page I'm getting the following error:
Notice: Undefined variable: moduleLoader in /Applications/MAMP/htdocs/zf-tutorial/application/Bootstrap.php on line 10
Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in /Applications/MAMP/htdocs/zf-tutorial/application/Bootstrap.php, line 10' in /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Response/Abstract.php:281 Stack trace: #0 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Response/Abstract.php(299): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Response/Abstract.php(727): Zend_Controller_Response_Abstract->sendHeaders() #2 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Front.php(974): Zend_Controller_Response_Abstract->sendResponse() #3 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch() #4 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Application.php(328): Zend_Application_Bootstrap_Bootstrap->run() #5 /Applications/MAMP/htdocs/zf-tutorial/public/index.php(26 in /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Response/Abstract.php on line 281
I'm running a MAMP server on Mac OS X.
Can anyone help me? Thanks!
May 27th, 2009 at 13:51 #
Hey,
now I'm having another problem.
Whem I'm trying to view http://localhost:8888/zf-tutorial/public/
of my MAMP on Mac OS installation
it says:
Add new album
An error occurred
Application error
Exception information:
Message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'zf.Model_DbTable_Albums' doesn't exist
Stack trace:
#0 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Db/Adapter/Abstract.php(467): Zend_Db_Statement->execute(Array)
#2 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Db/Adapter/Pdo/Abstract.php(235): Zend_Db_Adapter_Abstract->query('DESCRIBE `Model...', Array)
#3 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Db/Adapter/Pdo/Mysql.php(156): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE `Model...')
#4 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Db/Table/Abstract.php(727): Zend_Db_Adapter_Pdo_Mysql->describeTable('Model_DbTable_A...', NULL)
#5 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Db/Table/Abstract.php(770): Zend_Db_Table_Abstract->_setupMetadata()
#6 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Db/Table/Abstract.php(923): Zend_Db_Table_Abstract->_setupPrimaryKey()
#7 /Applications/MAMP/htdocs/zf-tutorial/application/models/DbTable/Albums.php(24): Zend_Db_Table_Abstract->insert(Array)
#8 /Applications/MAMP/htdocs/zf-tutorial/application/controllers/IndexController.php(33): Model_DbTable_Albums->addAlbum('The Killers', 'Day and Age')
#9 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Action.php(512): IndexController->addAction()
#10 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Dispatcher/Standard.php(288): Zend_Controller_Action->dispatch('addAction')
#11 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Front.php(936): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#12 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch()
#13 /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Application.php(328): Zend_Application_Bootstrap_Bootstrap->run()
#14 /Applications/MAMP/htdocs/zf-tutorial/public/index.php(26): Zend_Application->run()
#15 {main}
Request Parameters:
array(7) {
["controller"]=>
string(5) "index"
["action"]=>
string(3) "add"
["module"]=>
string(7) "default"
["id"]=>
string(0) ""
["artist"]=>
string(11) "The Killers"
["title"]=>
string(11) "Day and Age"
["submit"]=>
string(3) "Add"
}
databasename is: zf
tablename is: albums
I'm using default username/password: root
can anyone help me? Thanks!
May 27th, 2009 at 14:07 #
It looks like it's working now. I've removed a "?>" at the end of Albums.php
Thanks anyway.
May 27th, 2009 at 14:46 #
I followed the tutorial and everything works correctly, but When I modify your 4 record, I see:
It\'s Not Me, It\'s You
and not:
It's Not Me, It's You
There is a problem with quote...
May 27th, 2009 at 15:29 #
T3ch,
Turn off magic_quotes_gpc
Regards,
Rob...
May 28th, 2009 at 10:45 #
Thank's Rob. Your tutorial and your site are very usefully.
May 29th, 2009 at 06:59 #
Rob,
Great tutorial!
I was running some memory tests on this application, and I noticed that most pages use about 7 MB of memory for each script. I was using memory_get_peak_usage(). Isn't that a bit high for a web app such as this? I am new to ZF, so I may have no clue what I am talking about.
Thanks, Erich
May 31st, 2009 at 16:10 #
Hey. I'm having some trouble running zf.sh. It leaves me with the following notification:
/usr/local/ZendFrameworkCli/bin/zf.sh: 44: php: not found
Any advice on how to solve this?
May 31st, 2009 at 19:14 #
Marco,
I had the same issue. To fix it, run phpinfo() and check to make sure that your "include_path" is pointing to the correct directory. Make sure the "Zend" folder from the zend framework download is in that folder as well. That took care of the issue for me.
June 1st, 2009 at 12:41 #
Erich, thank you for your help. I havent been able to fix it on my localhost however. So I decided to put it on my 1and1 hosting space. That however leaves me with another error:
(uiserver):u47756847:~/ZendFramework-1.8.2/bin > zf.sh show version
Parse error: syntax error, unexpected T_STRING, expecting '{' in /path_to_my_hosting_directory/ZendFramework-1.8.2/library/Zend/Tool/Framework/Client/Console.php on line 63
I'm quite sure this is due to an older php version (4.*), since the line being mentioned (63) contains 'implements' (which is php 5 only).
1And1 does support php5 by using a htaccess file. So I tried creating a .htaccess file (AddType x-mapp-php5 .php) and it works fine when visiting pages through my browser. However when running the .sh file through SSH it still gives the error message. Any other solutions?
Thanks in advance!
June 1st, 2009 at 16:38 #
@Marco
you must write to 1and1 and not here. Who manages the server can respond to your request
June 1st, 2009 at 16:56 #
I agree with T3ch. There a lot of additional variables that come into play, especially with shared hosting. Honestly, Zend Tool is nice for some of the busy work at the start of the project, but if you're just starting to learn ZF, you can just download the tutorial and start playing with it.
June 2nd, 2009 at 22:12 #
Have an issue, don't think this is unique to your tutorial as I get same on Quickstart tutorial. My setup is:
Vista
Apache - 2.2.11
PHP - 5.2.9-2
MySQL - 5.1.3
The error is as follows:
My Albums
An error occurred
message ?>
Exception information:
Message: exception->getMessage() ?>
Stack trace:
exception->getTraceAsString() ?>
Request Parameters:
request->getParams()) ?>
Any Idea's ?!??
June 3rd, 2009 at 10:27 #
very helpful stuff.
i use module but i can't seem to get the autoloader to work. some pointers would be helpful.
June 6th, 2009 at 09:56 #
Hello
Tutorial is great, but i have still problem with adding new modules into tutorial code.
Is there anyone who could public tutorial code extended about (for example) two simple modules?
I'm searching web about it but there is no better tutorial than your's Rob but you give us only default module without IDEA of extending tutorial code for new modules.
Please help me (and many zf users) with some advice.
June 6th, 2009 at 11:43 #
Hi,
When I am placing index.php in root directory Then find folowing error.
Fatal error: Uncaught exception 'Zend_Config_Exception' with message 'parse_ini_file(D:\xampp\htdocs\zf1.8application\configs\application.ini) [function.parse-ini-file]: failed to open stream: No such file or directory' in D:\xampp\htdocs\zf1.8\library\Zend\Config\Ini.php:184 Stack trace: #0 D:\xampp\htdocs\zf1.8\library\Zend\Config\Ini.php(125): Zend_Config_Ini->_loadIniFile('D:\xampp\htdocs...') #1 D:\xampp\htdocs\zf1.8\library\Zend\Application.php(320): Zend_Config_Ini->__construct('D:\xampp\htdocs...', 'development') #2 D:\xampp\htdocs\zf1.8\library\Zend\Application.php(78): Zend_Application->_loadConfig('D:\xampp\htdocs...') #3 D:\xampp\htdocs\zf1.8\index.php(18): Zend_Application->__construct('development', 'D:\xampp\htdocs...') #4 {main} thrown in D:\xampp\htdocs\zf1.8\library\Zend\Config\Ini.php on line 184
Thanks.
June 8th, 2009 at 06:17 #
[...] click here OR [...]
June 9th, 2009 at 04:01 #
Rob,
I see you're using public function() in the Bootstrap, but the quickstart makes them protected. Was there a particular reason to make them public?
Thanks.
June 9th, 2009 at 08:51 #
Great tutorial! Helped me a lot!!!
I really had problems finding a tutorial to get started with Zend. Maybe they should offer more tutorials like this - the official Zend quickstart tutorial doesn't really help at all...
So thanks for this. Looking forward to an updated version of your Zend_Auth tutorial ;-)
June 9th, 2009 at 18:29 #
Marcus,
They should be protected.
Regards,
Rob...
June 11th, 2009 at 03:34 #
I think you meant me, but thanks Rob ;)
June 11th, 2009 at 20:31 #
Sorry, I have another question. In your model, you are extending Zend_Db_Table rather than Zend_Db_Table_Abstract as the manual and quickstart instructions. When are you supposed to use the former and when the latter?
June 12th, 2009 at 13:50 #
Joe,
Zend_Db_Table_Abstract is better choice. I'll update the tutorial.
Regards,
Rob...
June 14th, 2009 at 13:59 #
It seems to me as if in the PDF there are some lines missing.
Look for example at the beginning of page 6, the first phrase is incomplete it is missing something at the beginning.
Thanks for the tutorial.
June 16th, 2009 at 09:46 #
Sebastian,
Yeah there is :( I'll roll up a new one soon.
Rob...
June 16th, 2009 at 19:11 #
Rob & anyone still reading this far into the comments :)
I just wanted to mention that I stopped using the registry to hold the dbAdapter. It turns out if you add this line to your application.ini file (if you only connect to one database as most probably do):
resources.db.isDefaultTableAdapter = true
then in your model you can just do:
$this->_dbAdapter = Zend_Db_Table::getDefaultAdapter();
and remove the whole section in the bootstrap that initializes your dbAdapter and puts it in the registry.
June 17th, 2009 at 15:09 #
This is the best tutorial which i could found on the web!
Maybe someone can help me. I got
Fatal error: Uncaught exception 'Zend_Application_Bootstrap_Exception' with message 'Resource matching "layout" not found'
after completing 12 page of tutorial.
Im relatively new to PHP, and no wonder, to ZF...
June 17th, 2009 at 15:49 #
Michael,
I agree. Rob's book and online tutorials are a Godsend.
Try adding these lines to your application.ini:
resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] =
June 18th, 2009 at 05:40 #
[...] Framework (ZF from here on). For those just starting out with ZF, you definitely want to check out Rob Allen's tutorials and blog posts if you haven't already. Rob's examples are some of the best out there [...]
June 18th, 2009 at 06:16 #
Thanks, Joe!
Now I have a new errors %)
After fixing some of them I stuck with another one:
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'BaseUrl'
I have checked my files but without success. They all seems identical to what I can see in tutorial. I know that I made a mistake, but just doesnt see them
June 18th, 2009 at 07:58 #
Oh, I made a wrong cut. The full text:
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'BaseUrl' was not found in the registry
June 18th, 2009 at 15:46 #
Hello, Rob, you doing a great job, helping others to understand what is ZF is =)
I want to do a translate of your "Tutorial: Getting Started with Zend Framework 1.8" and place it on this page. Is it real? do you need this?
mail me please if you are interesting with it.
p.s.
mailto: enleonkiller (on) google mail.
June 18th, 2009 at 15:46 #
oh sorry, my fault.
p.p.s. i want to translate it into russian.
June 18th, 2009 at 15:57 #
David,
I'd love it if you do a translation! Give it a few days though until I upload the next one with some typo fixes in it.
Feel free to send it to me in PDF and I'll host it.
Rob...
June 18th, 2009 at 17:05 #
Hi Michael,
Hmmm, I have no idea what that error means. Hopefully Rob will figure it out or another guru will see it & comment.
June 18th, 2009 at 23:38 #
Ramco,
I too wanted to have the CASE_FOLDING attribute set in the application.ini file, this is what worked:
resources.db.params.options.caseFolding = 2
where 'caseFolding' is the value once the Zend_Db::CASE_FOLDING constant is evaluated and the int 2 is the value once the Zend_Db::CASE_LOWER constant is evaluated
for reference, CASE_UPPER = 1
June 19th, 2009 at 08:21 #
Hi,
I've tried your tutorial and it's works fine. Now I'm curios how I could read the record from the database in reverse order. So if I add a album, I want it to show up on top instead of at the bottom of the tabel.
How can this be done?
June 19th, 2009 at 08:24 #
Hi Rob,
great tutorial - helped me a lot.
One thing that doesn't work in my test.
In my layout.phtml file the title is not displayed:
escape($album->title); ?>
The headTitle is displayed correct.
Any ideas whaht i've made wrong?
Thanks,
Nils
June 19th, 2009 at 08:27 #
Sorry the line of code in my post is wrong. The correct line is on page 10 the line in the h1 tag.
June 22nd, 2009 at 00:20 #
[...] The code you are looking at is taken from Akra's DevNotes blog, Getting started with Zend Framework tutorial. [...]
June 24th, 2009 at 10:13 #
Thank you Rob for this tutorial!
I feel like i'm lost something.. i need to get request parameters in the bootstrap (like controller name and action name), but Zend_Controller_Request_Http::getModuleName, etc. is empty...
Can you please help?
Thank you!
Andrey
June 25th, 2009 at 04:01 #
[...] the Dodo Introduction post, I recommended staring with Rob Allen's tutorial and the QuickStart guide for those just starting out because they do a better job of going [...]
June 25th, 2009 at 06:53 #
Hi, Rob thanks for your tutorial
Its Great.
but i have problem with url having http://localhost/ZEND1.8/public/index/add.
It is getting me 404 error.
I also set the AllowOverride none in my httpd.conf file which is as follow :
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
can you help me ?
June 28th, 2009 at 01:36 #
Hello,
This is THE best tutorial for getting started with ZF. I understood what ws written, and the code worked, no problems at all.
Now do a Navigation tutorial.
5 years writing php and always something new to explore.
Thanks!
June 30th, 2009 at 12:55 #
Hi:
I'm kind of new using Zend, and I found a tutorial but I couldn't make my application work properly, it launches errors constantly, could anyone give me a link or anything so I can find an example that works with Zend 1.8 and has all the initial configuration of the application.ini, the .htacces and the boostrap.php???????
It's really important.
June 30th, 2009 at 23:07 #
Your tutorial is so good, easy to follow and understand, I have read many tutorials on the Internet, but the way of writing is so complicated, thank you so much.
BTW, I just bought your book, just read a few chapters, I love it, thanks.
July 1st, 2009 at 03:29 #
really nice tutorial!
thanks for doing it.
July 1st, 2009 at 19:46 #
great tutorial, very well written.thank you very much
July 2nd, 2009 at 14:26 #
Hi!
I'm very new in ZendFramework and I have this problem I dont know what should configure for work with Zend_Db_Table_Abstract because if I create my class in this way :
class Clientes extends Zend_Db_Table_Abstract and in my controller I create an object
$Clientes = new Clientes();
when I try my application the output is
Fatal error: Class 'Clientes' not found in /home/miriam/zend_proyects/new_zend/application/controllers/IndexController.php on line 21
and the line 21 is where I instance the object.
What should I add for get it work.
My boostrap file is this:
'',
'basePath'=> APPLICATION_PATH));
return $moduleLoader;
}
function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Zend Framework Tutorial');
}
and my index.php is this
bootstrap()
->run();
Thanks in advance.