Tutorial: Getting Started with the Zend Framework 1.0

This tutorial is intended to give a very basic introduction to using the Zend Framework to write a simple database driven application.

NOTE: This tutorial has been tested on version 1.0.0 of the Zend Framework. It stands a very good chance of working with later versions. It is unlikely to on any version prior to version 1.0.0 due to dependency on the ViewRenderer action helper.

English version: Dowload the PDF (v1.4.5).
Simplified Chinese version by Jason Qi (offsite): Visit Jason's download area.
French version by Guillaume Rossolini (offsite): Débuter avec le Zend Framework.
Polish version by Kubek Bartosz (offsite): Pierwsze kroki z Zend Framework.
Russian version by Alex Musayev (offsite): Russian Translation (PDF)
Czech version by Petr Parimucha (offsite): CzechTranslation
Brazillian Portuguese version by Ricardo Klein (offsite): Getting Started with Zend Auth_pt-BR
Latvian version by Ingus (offsite): Ievads Zend Framework
Slovakian version by Igor Hlina (offsite): Začíname so Zend Frameworkom - tutoriál

Translations for previous versions of this tutorial:
Brazillian Portuguese version by Adler Medrado: Iniciando com Zend Framework (1.3.0).
German translation by Daniel Messer: Einstieg in das Zend Framework: PDF (v1.3.0).
Danish translation by Stig Benning: I gang med Zend Framework: PDF (v1.3.4).
Spanish translation by Claudio Cossio (offsite): Desarrollo de Aplicaciones con Zend Framework: PDF (v1.3.3).
Indonesian version by Riki Risnandar: Tutorial Awal dengan Zend Framework PDF (v.1.2.3)
Italian version by Fabrizio Frosali: Primi passi con il Framework Zend (off site).

Code

The associated code is available:

Changelog

1.4.5
Made the dependencies on mod_rewrite and .htaccess files more obvious.
1.4.4
Use createRow() to create an "empty" album as noticed by Terry Stalker. Also, fixed reference to $_SERVER[’REQUEST_METHOD’] as reported by balu!
1.4.3
Further updates so that the flow makes sense!
1.4.2
Updates to support version 1.0.0. of the Zend Framework
1.4.1
Updates to support version 1.0.0. RC2of the Zend Framework
1.4.0
Updates to support version 1.0.0. RC1 of the Zend Framework.
1.3.4
Improvements to the English found by Guillaume Rossolini.
1.3.3
Another typo! Found by Wayne Roesner.
1.3.2
More typos fixed. Found initially by Ludo, then many others ;)
1.3.1
Now using isPost() as suggested by sleek. Also filed typos found by Jason Qi.
1.3.0
Significant reworking to support version 0.9 of the Zend Framework.
1.2.4
Typographical fixes found by Darren Chandler. This version has been tested on 0.8 of the Zend Framework.
1.2.3
Updated notes on which versions of the Zend Framework are supported, now that I've tested on 0.7.
1.2.2
Fixed more typographical and contextual issues found by Jason Qi.
1.2.1
First typo found by Jason Qi.
1.2.0
Updated tutorial for version 0.6 of the Zend Framework.
1.1.1
Fixed setting of the include path.
Fixed multiple typos found by Brendon Kozlowski.
1.1.1
Fixed initiation of the Front Controller in index.php.
1.1.0
Updated tutorial for version 0.2 of the Zend Framework.
1.0.5
Added some troubleshooting information about using setRewriteBase().
1.0.4
Maybe I've finally nailed down the path to IndexController.php!
1.0.3
More minor fixes. Thanks Thanks Holger and Develucas! Added note about only working with 0.1.5.
1.0.2
Typo fix. Thanks Chris!
1.0.1
Multiple minor fixes. Thanks Nathan, Nick, Matthew and everyone else!
1.0
Original version

554 Responses to “Tutorial: Getting Started with the Zend Framework 1.0”

  1. 1 edwood

    Thanks for this great tutorial!

    greets from germany
    ed

  2. 2 Jay Keith

    Great tutorial!

    I've been looking for this, and it has helped me tremendously!

  3. 3 markdbd

    Great work, thanks :D

  4. 4 dedenf

    thank you for the tutorial :)

  5. 5 stefano

    great tutorial, now i want to use zend framework but my hosting have php 4.* :P

    thank you for the tutorial :)

  6. 6 gerardo

    zip file 1.0.1 does not exist :(

  7. 7 Robert

    Great tutorial, but I still don't understand how the models work. i.e. when I have a model for some newsposts how can I combine those posts with the right category (that's a different model I think).

    Ow, and at page 11: "$this->actionTemplate" should be "$view->actionTemplate".

    The rest is Great!

  8. 8 gerardo

    Linked download is the old PDF (v1.0)
    Download the new PDF (v.1.0.1):
    http://www.akrabat.com/wp-content/uploads/getting-started-with-the-zend-framework_101.pdf

  9. 9 nwrafa

    zip file 1.0.1 does not exist :(

  10. 10 Michael Krenz

    Sorry, but I'm also having trouble with not finding the ZIP... Otherwise, great tutorial!

  11. 11 Rob...

    Sorry, been away for a few days on holiday (without a computer!)

    I've fixed the links. The changes I made were to the PDF, not the zip file, but I updated the post incorrectly.

    You should now be able to dowload a version 1.0.1 of the PDF.

  12. 12 carlo

    i have problems in 6th page. When i try to test IndexController with a url like http://localhost/zf_tutorial/index/add i'm notice with:

    Fatal error: Uncaught exception Zend_Controller_Action_Exception with message 'IndexController::norouteAction() does not exist and was not trapped in __call().' in c:\arquivos de programas\apache group\Apache\htdocs\zf_tutorial\library\Zend\Controller\Action.php:92 Stack trace: #0 c:\arquivos de programas\apache group\Apache\htdocs\zf_tutorial\library\Zend\Controller\Action.php(92): Zend_Controller_Action::__call() #1 c:\arquivos de programas\apache group\Apache\htdocs\zf_tutorial\library\Zend\Controller\Action.php(114): IndexController->__call('norouteAction', Array) #2 c:\arquivos de programas\apache group\Apache\htdocs\zf_tutorial\library\Zend\Controller\Dispatcher.php(185): IndexController->run(Object(Zend_Controller_Dispatcher), Object(Zend_Controller_Dispatcher_Token)) #3 c:\arquivos de programas\apache group\Apache\htdocs\zf_tutorial\library\Zend\Controller\Dispatcher.php(136): Zend_Controller_Dispatcher->_dispatch(Object(Zend_Controller_Dispatcher_Token), true) #4 c:\arquivos de programas\apache group\Apache\htd in c:\arquivos de programas\apache group\Apache\htdocs\zf_tutorial\library\Zend\Controller\Action.php on line 92

  13. 13 Rob...

    Carlo,

    Do you have a function called addAction() in your IndexController class?

  14. 14 etng

    Thank you for your excellent tutorial.I'd like to transelate it into Chinese,Can you grant me this privilege?

  15. 15 Rob...

    etng,

    Please feel free to translate to Chinese, as long as you credit me as the original author.

  16. 16 Dan

    I'm going through your tutorial right now, and so far it's awesome. One note though - I've had trouble with the initial mod_rewrite rules for when this app exists in a subdirectory. When I changed the rules to this for the zf-tutorial/.htaccess file it worked:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule !\.(js|ico|gif|jpg|png|css)$ /~danServe/zf-tutorial/index.php

    Is there a better way to do this?
    fyi: I'm running this via Apache 1.3 on Tiger, using PHP 5.1.x

    Thanks!

  17. 17 Rob...

    Hi Dan,

    From what I can tell, the automatic working out of the base URL by the RewriteRouter doesn't work in certain cases.

    There's no real current solution yet, so fixing the rewrite rules seems as good a way as any to me.

  18. 18 Holger Szillat

    Great work! Really got me into working with the Zend-Framework. Thanks!

    One note though: In the 'IndexController' in your 'addAction' you are not setting the id-property of the album, resulting in a "Property not found..."-error in the HTML-page as the value for the hidden Id-field. This is not a problem in the code, since the id-field is not considered when adding an album, but if someone looks at the HTML-code, it's ugly.

    (Running the code on a PHP-5.1.4 with Hardening-Patch.)

  19. 19 Rob...

    Thanks for that Holger!

  20. 20 Noury

    hai Rob i'm from holland i vound your tutorial super.I want to ask je of you can make a tutorial with INNER JOIN. Thanks

  21. 21 Rob...

    Hi Noury,

    Who knows what the future will bring :)

    Regards,

    Rob...

  22. 22 lamonato

    great job!

  23. 23 Noury

    Hai rob Can i do this:

    $view->homepage = $homepage->fetchAll("SELECT * FROM homepage");

    -----------------------------

    function indexAction()
    {
    $view = Zend::registry('view');
    $homepage = new Homepage();
    $view->homepage = $homepage->fetchAll();
    $view->homepageactionTemplate = 'homepageIndex.tpl.php';

    $rubrieken = new Rubrieken();
    $view->rubrieken = $rubrieken->fetchAll();
    $view->rubriekenactionTemplate = 'rubriekenIndex.tpl.php';

    echo $view->render('site.tpl.php');

    }

  24. 24 Rob...

    Noury,

    I don't see why not. Obviously, you have to render() both homepageactionTemplate and rubriekenactionTempate from within site.tpl.php.

  25. 25 Noury

    HOlla ROB How are you?

    Do you have any idee how i use join() in your tutorial.

    Thanks

  26. 26 Jared

    On page 4, you say: "Note that we do not put in the ?> at the end of the file as it is not needed and leaving it out ca prevent some hard-to-debug errors."

    This is the first time I have heard of this. Where can I find more info on this concept?

  27. 27 Rob...

    Hi Jared,

    http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html mentions it at the top.

    Regards,

    Rob...

  28. 28 Rob...

    Noury,

    What you do you mean?

    Regards,

    Rob...

  29. 29 Pawel

    I have problem with tutorial.
    its probably in this line: render($this->actionTemplate); ?>

    message is:

    Warning: Zend_View::include(./application/views\) [function.Zend-View-include]: failed to open stream: Permission denied in D:\new_wamp\www\zf_tutorial\library\Zend\View.php on line 46

    Warning: Zend_View::include() [function.include]: Failed opening './application/views\' for inclusion (include_path='.;./library/;./application/models') in D:\new_wamp\www\zf_tutorial\library\Zend\View.php on line 46

  30. 30 Pawel

    render($this->actionTemplate); ?>
    its on page 9. Probably script cut part of line so i put spaces now.

  31. 31 Rob...

    Hmm... that's odd as it implies that the actionTemplate variable is empty.

  32. 32 Mark

    Good looking tutorial although I cannot get anything other than IndexController working.
    I need multiple possibilities for the controller, as mentioned in the tutorial, but not added.

    Example:
    / - uses index controller IndexController.php indexAction method
    /index/add should use IndexController.php addAction method
    /dummy - should use DummyController.php indexAction method
    /dummy/new should use DummyController.php newAction method

    How would you set this up using the router if necessary ?

  33. 33 Noury

    Hallo rob,
    Would you like to tell me hoe i can use join().
    I don't know where i put join() and how.
    I have a news table and a user table. Every news a written by a user:

    class news extends Zend_Db_Table{}.
    class user extends Zend_Db_Table{}.

    thank you very much
    Nour

  34. 34 kico

    Hi,
    I have this error using the tutorial:

    Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The mysql driver is not currently installed' in C:\wamp\www\zf-tutorial\library\Zend\Db\Adapter\Pdo\Abstract.php:80 ... I didn't put the stack trace

    I'm in page 14 (version 104)

  35. 35 Rob...

    kico,

    You need to enable PHP's MySQL extension in the php.ini file.

    Regards,

    Rob...

  36. 36 kico

    Rob:
    I already did, I'm using WAMP5, that was the first thing i thought too, but still nothing

    Regards

  37. 37 kico

    I'm using ZendStudio 5.1 too

  38. 38 Rob...

    kiko,

    Have you also enabled the PDO MySQL extension?

    Rob...

  39. 39 kico

    I did that too...

    Regards

  40. 40 kico

    Rob:
    I could connect to mysql using prado framework, so the driver works
    but still have the same error using Zend

    regards

  41. 41 kico

    problem solved
    i just had to restart windows, i don't know what was it, but its fixed
    thank you

  42. 42 Rob...

    Kico,

    That's very odd. Glad it's solved though!

    Rob...

  43. 43 Dragos Raileanu

    Thx for the tutorial, helps a lot because it gives you the basics of understanding how this framework works, not very in-depth... initially i had v.10 (which had the bug of $this instead of $view, and only after i've figured out myself i got to see v101). Still, sometimes I have doubts about real applications needsing the whole structure, because it could be a terrible overload on a machine to have, let's say, 300 sites (simple, small ones) running with zend framework. Some preliminary tests showed me a good degree of slowing down everything, and a pretty high increasing of memory consumption. It is obviously, extremely good for organizing everything very well, and all maintenance/upgrades. And very good to know all the things in order to have a better overview of large apps, but probably most of the people will not even take the time to look for a tutorial, and, in case they don't find one like yours, they'll give up zend framework, and continue using some older ones, tested and known.

    Regards,
    Dragos

  44. 44 Dragos Raileanu

    Well, another error I've found right now on page 13, under "Listing Albums". It says: zf-tutorial/application/views/IndexController.php with the lines function __construct().... Well, it happens that this is not the controller we're looking for, but instead, that controller resides in /application/controllers/IndexController.php
    Same thing couple of lines below, again, where we add the code for instantiating and fetching the albums list... Please correct the tutorial, man, as it will never bring people to something usable (but I still appreciate a lot your effort, so let's make it work as well as it could).

    Regards
    Dragos

  45. 45 Dragos Raileanu

    oops, sorry, I've only now found the v1.0.4 :) .. it was too visible to see it, my apologies please

  46. 46 Rob...

    Hi Dragos,

    Thanks for the comments. As you can see, I've tried to sort out the typos and I'm vaguely hopeful that 1.0.4 is typo free. Of course, if you find anything, please let me know and I'll fix it!

    Regards,

    Rob...

  47. 47 tom

    same problem as Comments#29 (but on linux), variable was empty

    I changed
    $this->actionTemplate = 'indexIndex.tpl.php';
    into
    $view->actionTemplate = 'indexIndex.tpl.php';

    and it works fine...

  48. 48 Dave

    Hi there,

    I want to add my thanks for a great tutorial. I do have a problem however. Exactly the same error as described in comment 12. I do have the IndexController.php file setup as in the tutorial and have a function called AddAction in the Controller class.

    I can access zf_tutorial/ which echos 'in IndexController::indexAction()' but zf_tutorial/index/add or zf_tutorial/index/edit result in the error:

    Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::norouteAction()...etc

    I'm running php PHP 5.1.6 and Apache 1.3 on Mac OSX 10.4.7 with Zend Framework 0.1.5

    I've double checked everything and can't figure it out. Would appreciate any suggestions.

    Thanks

  49. 49 Dave

    Problem solved. It was to do with having my application in a subfolder although I tried all of the fixes suggested above and nothing seemed to work. In the end I added this to the bootstrap file:

    $route->setRewriteBase('/~my_osx_username/zf_tutorial');

    Working fine now

  50. 50 Rob...

    Hi Dave,

    From what I've learnt so far, I think that setRewriteBase() is the most reliable way to get rewrite routing working. I'll update the tutorial soonish to reflect this.

    Regards,

    Rob...

  51. 51 Rob...

    Tom,

    Which page of the tutorial, in which version?

    Regards,

    Rob...

  52. 52 Hasan

    Hi Rob!!
    I have the same problem as Dave described.
    Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The mysql driver is not currently installed' in C:\wamp\www\zf_tutt\library\Zend\Db\Adapter\Pdo\Abstract.php:8..etc
    where should I make the changes ??
    Thnx for a great tut.

  53. 53 Rob...

    Hasan,

    You need to ensure that the mysql driver and the PDO mysql driver are enabled in your php.ini.

    Regards,

    Rob...

  54. 54 Hasan

    Done!! I use WAMP, I made the changes in wamp/PHP/php.ini and it didn't work. But when I made the changes in C:\wamp\Apache2\bin\php.ini i start to work .
    Thnx again ..
    Hasan..

  55. 55 Rob...

    Multiple php.ini files in a system can cause a world of pain. Glad you got it sorted!

    Regards,

    Rob...

  56. 56 John

    Posting this in case anyone else has similar difficulties...

    Apache/2.0.59 (Unix) Server
    PHP Version 5.1.6
    MySQL API 5.0.22

    I am stuck at page 6 in the tutorial (zf-tutorial/application/controllers/IndexController.php).

    I am having the same fatal error as some other folks (see mssg 12 & 48), but their solutions in my environment haven't removed the error.

    FYI, I just reviewed my directory structure and code against your Subversion repository. No difference for the pertinent components/code that I see (but am sure there is something).

    In index.php.addRoute(), I can change the default action to get each function to display its message as the default or Index action (wierd).

    That is,
    if:
    $route->addRoute('edit', ':controller/:action/id/:id',array('controller' => 'index','action' => 'index'));
    then:
    1. requesting wwwroot(aka html)/zf-tutorial displays "in IndexController::indexAction()"
    2. requesting wwwroot(aka html)/zf-tutorial/index displays "in IndexController::indexAction()"
    3. requesting wwwroot(aka html)/zf-tutorial/add encounters norouteAction() - fatal error

    if:
    $route->addRoute('edit', ':controller/:action/id/:id',array('controller' => 'index','action' => 'add'));
    then:
    1. requesting wwwroot(aka html)/zf-tutorial displays "in IndexController::addAction()"
    2. requesting wwwroot(aka html)/zf-tutorial/index displays "in IndexController::addAction()"
    3. requesting wwwroot(aka html)/zf-tutorial/add encounters norouteAction() - fatal error

    So this seems like one of those scope problems that always give me headaches. :-)

    Anyway still reading the manual and going in circles.

  57. 57 Rob...

    John

    Have you tried setting the rewrite base?

    $router->setRewriteBase('/zf-tutorial');
    

    Regards,

    Rob...

  58. 58 John

    Thanks for the response.
    I wasn't clear in my post yesterday and I did not give you a full picture. Sorry.
    My guess is the problem is likely environmental since none of the coding solutions here, Craig Shiflett's site or the Manual seem to get me a proper result.

    To answer your question, 'Yes'. When I try to setRewriteBase, this message results"
    mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.

    The operations seems to want more than 10 redirects?
    MaxRedirects is 10 which is the most this server allows apparently. Guess I can submit a support ticket to find out more.

    Thanks.

  59. 59 Justin Hendrickson

    Are the .htaccess files with 'deny from all' even necessary? Wouldn't the 'RewriteRule .* index.php' catch any access to the application and libraries directories and interpret the request through the index.php file, or am I missing something?

  60. 60 Rob...

    Justin,

    You are almost certainly right as there aren't anre RewriteCond's to allow through files that exist on the hard drive.

    Regards,

    Rob...

  61. 61 Pádraic Brady

    I still use "deny from all" too ;). Totally unnecessary but it just feels safer, and it does no harm either.

  62. 62 zman

    same error like #12 comment

    error on requested page http://localhost/zf_tutorial/index/add

    solved thus:

    just replace
    $router->setRewriteBase($baseUrl);

    with subfolder tutorial
    like this one
    $router->setRewriteBase('/zf_tutorial');

    ``````
    Apache/1.3.33 (Win32) PHP/5.1.6

  63. 63 Noury

    he Rob, you promised us to write a login script with zf.

  64. 64 Rob...

    Noury,

    I haven't forgotten!

    Regards,

    Rob...

  65. 65 Matt

    Hey Rob, Great tutorial.

    I'm having an issue however:
    Fatal error: Uncaught exception 'Zend_Exception' with message 'File "Album.php" was not found.' in /var/www/zend.onlinedyno.com/library/Zend.php:190

    I first thought maybe I had set things up incorrectly as I went through your tutorial but then I downloaded your code and reset config.ini to my values and I get the same error.

    Any thoughts?

    Thanks,
    Matt

  66. 66 Matt

    Quick followup. I was able to get past my error by adding the following to my .htaccess
    php_value include_path .:/var/www/zend.onlinedyno.com/zf-tutorial/application/models/

    Doesn't seem like the best solution so let me know if I'm missing something obvious.

  67. 67 Matt

    Hey Rob, I swear I'm not trying to spam your blog but here's a solution I found that works for $baseUrl. I think it should work as long as your application is in the root of a site.

    $baseUrl = substr($_SERVER['DOCUMENT_ROOT'],strrpos($_SERVER['DOCUMENT_ROOT'],'/'));

  68. 68 Rob...

    Hi Matt!

    In your index.php you should have included application/models into the include-path with a statement like:

    
    set_include_path('.' PATH_SEPARATOR './library/' 
       PATH_SEPARATOR './application/models' 
         get_include_path()); 
    
    

    I'm wondering if the set up you are using means that when running index.php, the current working directory is not the same directory as the one that index.php is in.

    To check, change this bit to:

    
    set_include_path('.' PATH_SEPARATOR './library/' 
       PATH_SEPARATOR dirname(__FILE__) . '/application/models' 
         get_include_path()); 
    
    

    and see if that works.

    It still seems that getting the right baseURL is very much system dependant :(

    Regards,

    Rob...

  69. 69 Matt

    Hey Rob,

    I'm a bit perplexed. After working with it a bit and removing my php_value from .htaccess here's what I ended up with:

    set_include_path(get_include_path().PATH_SEPARATOR.'./library/'.PATH_SEPARATOR. './application/models');

    And then if I echo get_include_path() afterwards I get:
    .:/usr/share/php:./library/:./application/models

    The original set include gave me a get_include_path() of:
    .:./library/:./application/models.:/usr/share/php

    I don't see the difference other than the order but it absolutely won't work with the original path and it works flawlessly with my modified one. Ah wait... There's an extra . after models in the original. That's what is breaking it. We need another PATH_SEPARATOR in there so it becomes:

    set_include_path('.' . PATH_SEPARATOR . './library/'
    . PATH_SEPARATOR . './application/models'. PATH_SEPARATOR
    . get_include_path());

    Other than that, your tutorial has really sparked my interest in the framework. I wish it was a bit more mature but they're off to a great start with it!

  70. 70 Dave Cassidy

    If anyone else is getting the following error:

    Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::norouteAction() does not exist and was not trapped in __call().'

    Have a look at this revision. Seems to work well for me. The problem seems to occur only when using _redirect() to redirect the user back to the indexAction(). Instead of redirecting, why not just executing it?

    Here's the revised code:
    http://pastebin.com/823169 (Note the highlighted portion.)

  71. 71 Matt

    Hey Dave,
    I just defined a noRouteAction that gives a 404 error.

  72. 72 Dave Cassidy

    Matt,

    What happens then when you just point to your root directory without passing an entire :controller/:action string?

    For example, try http://www.yourdomain.com instead of http://www.yourdomain.com/index/index. The noRouteAction() method should be called, I'd guess. If that is the case, that would render your application unusable for anyone that doesn't know an exact path to your main index. That's precisely what happens when I try the same - unless I have done something wrong here, and I think my code is pretty sound.

    Additionally, I am not very fond of error pages. I chose to redirect to the main index in case of a 404.

    If you are interested, you can take a look at my slightly more complicated example (which uses the Smarty template engine instead of Zend_View) here: http://harbinger.pastebin.com/823168

    Keep in mind that this script is work in progress and don't be too harsh in juding. :)

  73. 73 Rob...

    I think the problem is that there's a bug in the tutorial, right at the bottom of index.php:

    
    $controller->run('./application/controllers'); 
    

    should be:

    
    $controller->setControllerDirectory('./application/controllers');
    $controller->dispatch(); 
    
    

    Otherwise, the normal router is used rather than the the rewrite one.

    I've updated the PDF and the zip file.

    Regards,

    Rob...

  74. 74 Dave Cassidy

    Thanks, Rob. Looks like we all missed this one. It's so hard keeping it straight, though, when the design of the application changes like this and the developers are slow to update documentation. Still... Zend Framework is living up to the hype.

  75. 75 Hasan

    Hi!!
    Does anything of this tutorial changes with the new zf 0.2 release??

    reguards

  76. 76 Rob...

    Yes Hasan,

    That's why I released a new version :)

    Regards,

    Rob...

  77. 77 John

    This is not the venue, but my asking stems from the goodness of this tutorial.

    First though...
    Thanks for this tutorial; it has been such a great help (education, motivation, etc.)!

    It works so well in my Unix test environment that I took the plunge and set up a local WAMP environment.
    Voila! The same code would not work under Windows. I'd get an Undefined Property error on the $config object.

    Here is the offending code that works pefectly in UNIX, but not in Windows:

    db->adapter, $config->db->config->asArray());
    Zend_Db_Table::setDefaultAdapter($db);
    ?>

    In a ZF manual code sample, I found that Config.php and Config/Ini.php are required
    (http://framework.zend.com/manual/en/zend.config.html#zend.config.introduction).
    Applying this change to my WAMP environment fixed the problem... why?
    (please don't say, "Windows is like that!" heeh =) )
    I bet I still have some configuration issue in the local WAMP environment. Still looking.

    Anyway, here is the segment that works in WAMP.
    db->adapter, $config->db->config->asArray());
    Zend_Db_Table::setDefaultAdapter($db);
    ?>

    Thanks

  78. 78 John

    Oops, that code sample did not post very well.

  79. 79 Rob...

    John,

    I wrote the tutorial using my Windows box running Apache 2, so it's not a generic Windows problem. There's no reason why you would have to require Config.php as Config/Ini.php will include it for you.

    Out of interest, are you running APC or something similar on Windows?

    Regards,

    Rob...

  80. 80 Jason

    When I click on 'Add new album'

    I got this

    http://localhost/zf_tutorial/index/add

    Not Found

    The requested URL /zf_tutorial/index/add was not found on this server.
    Apache/2.0.59 (Win32) PHP/5.1.6 Server at localhost Port 80

    Thanks.

  81. 81 Rob...

    Jason,

    If I was to guess, I'd say that there's a mod_rewrite problem.

    Regards,

    Rob...

  82. 82 christian

    OH THANK YOU THANK YOU THANK YOU! it had just what i needed to know about! :)

    - now i only need one thing. How to work with the rewrite router controller from the config file.

  83. 83 andrew taylor

    Hi,

    Thanks for the tutorial.

    Does $this->_action->getParams() inherently use Zend_Filter_Input ?

    Obviously using the bootstraping principal, my URL will look something like:

    example.com/Foo/Bar/id/45

    Which will give me id=>45 from getParams().

    However, this input still needs to be filtered, new Zend_Filter_Input($_GET) won't give me id=>45 unless I build my URL as:

    example.com/Foo/Bar?id=45.

    Your thoughts would be appreciated.

    Thanks

    Andrew

  84. 84 Rob...

    Andrew,

    As far as I know, getParams() doesn't use Zend_Filter_Input, so you should put it through one of the Zend_Filter methods first.

    Regards,

    Rob...

  85. 85 andrew taylor

    Thanks that works great, I've got a little internal app coming up in the next month or so, I'm going to use the opportunity to flex the framework a little.

    It all looks very positive, and, with Zend behind it, it's got legs.

    Andrew

  86. 86 Jeremy

    I agree with comment #69. I needed to add either of the following two things after .application/models :

    1.) Add a '/' after ./application/models OR

    
    date_default_timezone_set('AMERICA/NEW YORK');
    set_include_path('.' PATH_SEPARATOR './library/'
    PATH_SEPARATOR './application/models/'
    get_include_path());
    
    

    2.) Add . PATH_SEPARATOR after './application/models'

    
    date_default_timezone_set('AMERICA/NEW YORK');
    set_include_path('.' PATH_SEPARATOR './library/'
    PATH_SEPARATOR './application/models'.PATH_SEPARATOR
    get_include_path());
    
    

    Thank you for the tutorial!

  87. 87 Jason

    Hi Rob,

    How can I solve the mod_rewrite problem?

    BTW, another questions is

    When I type http://mysite/ I can see the right page.
    When I type http://mysite/index.php, nothing showes up.

    Thanks a lot.

    Jason.

  88. 88 Jason

    Hi Rob,

    Sorry, I solved that problem by modifying my httpd.conf file to enable mod_rewrite and allow apache to access .htaccess.

    But now, whenever I click "add new album", nothing showes up.

    I only can see "http://mysite/zf-tutorial/index/add" in the address bar of the firefox.

    Thanks.

    Jason.

  89. 89 Jason

    oh, I read someone else's comments and tried to replace $baseUrl by '/zf-tutorial' and everything works fine now!!!

    Thanks for your great tutorial!!!

    What I did in the index.php are:

    //$router->setRewriteBase($baseUrl);
    $router->setRewriteBase('/zf-tutorial');

    But still, when I type "http://mysite/index.php" and get nothing.

    Jason.

  90. 90 Jason

    I found http://mysite/index works.

    So if index.php can be converted to index somewhere, it will be great.

  91. 91 Rob...

    Jason,

    Are there any error messages in your Apache error log ?

    Regards,

    Rob...

  92. 92 Pooja

    Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The mysql driver is not currently installed' in /usr/local/apache-1.3.36/htdocs/somedomain.com/dev/library/Zend/Db/Adapter/Pdo/Abstract.php:80 Stack trace: #0 /usr/local/apache-1.3.36/htdocs/somedomain.com/dev/library/Zend/Db/Adapter/Abstract.php(146): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 /usr/local/apache-1.3.36/htdocs/somedomain.com/dev/library/Zend/Db/Adapter/Abstract.php(309): Zend_Db_Adapter_Abstract->query('DESCRIBE album', NULL) #2 /usr/local/apache-1.3.36/htdocs/somedomain.com/dev/library/Zend/Db/Adapter/Pdo/Mysql.php(86): Zend_Db_Adapter_Abstract->fetchAll('DESCRIBE album') #3 /usr/local/apache-1.3.36/htdocs/somedomain.com/dev/library/Zend/Db/Table.php(181): Zend_Db_Adapter_Pdo_Mysql->describeTable('album') #4 /usr/local/apache-1.3.36/htdocs/somedomain.com/dev/library/Zend/Db/Table.php(123): Zend_Db_Table->_setup() #5 /usr/local/apache-1.3.36/htdocs/somedomain.com/dev/application/controllers/IndexController.php(15): Zend_Db_Table->__constru in /usr/local/apache-1.3.36/htdocs/somedomain.com/dev/library/Zend/Db/Adapter/Pdo/Abstract.php on line 80

    I have PDO installed

    PDO
    PDO support enabled
    PDO drivers sqlite2
    PHP Extension 20050922

    I am still not able to connect to database. Can u pls help me with this.

    Thnx
    Pooja

  93. 93 Rob...

    Hi Poogja,

    Have you installed the MySQL PDO driver?

    i.e. extension=php_pdo_mysql.dll or extension=php_pdo_mysql.so (depending on system!)

    Regards,

    Rob...

  94. 94 Jason

    Rob,

    There is no related error message in the apache error log file.

    I have two WAMPs, one is winxp pro sp2+apache 2.0.59+php5.1.6
    when I type index.php there is nothing shows up

    another one is winxp home sp2+apache 1.3.37+php5.1.6
    when I type index.php there is error message shows up as follow

    Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::norouteAction() does not exist and was not trapped in __call().' in c:\zf-tutorial\library\Zend\Controller\Action.php:92 Stack trace: #0 c:\zf-tutorial\library\Zend\Controller\Action.php(114): Zend_Controller_Action->__call('norouteAction', Array) #1 c:\zf-tutorial\library\Zend\Controller\Dispatcher.php(185): Zend_Controller_Action->run(Object(Zend_Controller_Dispatcher), Object(Zend_Controller_Dispatcher_Token)) #2 c:\zf-tutorial\library\Zend\Controller\Dispatcher.php(136): Zend_Controller_Dispatcher->_dispatch(Object(Zend_Controller_Dispatcher_Token), true) #3 c:\zf-tutorial\library\Zend\Controller\Front.php(254): Zend_Controller_Dispatcher->dispatch(Object(Zend_Controller_Dispatcher_Token)) #4 c:\zf-tutorial\index.php(46): Zend_Controller_Front->dispatch() #5 {main} thrown in c:\zf-tutorial\library\Zend\Controller\Action.php on line 92

  95. 95 Jason

    Rob,

    Sorry, the info in the last post is not clear.

    Today, when I back home, I checked apache 2.0.59's error log, found error message like this (looks like same with apache1.3.37 which shows in the browser)

    [Sat Nov 25 00:01:03 2006] [error] [client 192.168.1.100] PHP Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::norouteAction() does not exist and was not trapped in __call().' in C:\\zf-tutorial\\library\\Zend\\Controller\\Action.php:92\nStack trace:\n#0 C:\\zf-tutorial\\library\\Zend\\Controller\\Action.php(114): Zend_Controller_Action->__call('norouteAction', Array)\n#1 C:\\zf-tutorial\\library\\Zend\\Controller\\Dispatcher.php(185): Zend_Controller_Action->run(Object(Zend_Controller_Dispatcher), Object(Zend_Controller_Dispatcher_Token))\n#2 C:\\zf-tutorial\\library\\Zend\\Controller\\Dispatcher.php(136): Zend_Controller_Dispatcher->_dispatch(Object(Zend_Controller_Dispatcher_Token), true)\n#3 C:\\zf-tutorial\\library\\Zend\\Controller\\Front.php(254): Zend_Controller_Dispatcher->dispatch(Object(Zend_Controller_Dispatcher_Token))\n#4 C:\\zf-tutorial\\index.php(49): Zend_Controller_Front->dispatch()\n#5 {main}\n thrown in C:\\zf-tutorial\\library\\Zend\\Controller\\Action.php on line 92

  96. 96 Rob...

    Jason,

    Fancy zipping up your project and emailing it to me?

    Regards,

    Rob...

  97. 97 Jason

    Rob,

    I sent it to you.

    Thanks.

  98. 98 R.V.

    The Polish translation links, in fact, to the Italian version and vice versa.

  99. 99 Rob...

    Doh!

    Thanks R.V! I've updated :)

    Regards,

    Rob...

  100. 100 Bruno

    Rob,

    This is the best tutorial I've seen for a long time! It is very clear and everything works first time. Coming from a Java and more recently Ruby on Rails background, I was very frustrated by PHP for the lack of a good MVC framework. The Zend framework has now changed this.

    Thank you for a brilliant introduction to this technology!

    Bruno

  101. 101 Rob...

    Thanks for your kind words, Bruno!

    Regards,

    Rob...

  102. 102 Cookdav

    Yes, very nice tutorial!

    To exercise the Zend MVC framework, I've
    used the 'chat tutorial' code. They, in turn,
    use a 'library incubator' sub-directory to
    contain ZF code (so that each using app contains
    a private copy of ZF).

    My comment/question is that it would be neat
    if ZF provided a method to make it easy for
    the using-app to retrieve/display the VERSION of
    ZF that is in use (and show a URL-link to where it comes from,etc), so that one coulld easily see
    what version is being used.

    Meanwhile, anyone know WHERE to look in the sub-tree to determine what version of ZF is
    located there?

    TIA...

    Dave

  103. 103 Rob...

    Dave,

    To be hones, I haven't a clue if the current release version is in the tree.

    Regards,

    Rob...

  104. 104 eugene

    getting error:
    Catchable fatal error: Argument 1 passed to Zend_Controller_Action::__construct() must be an instance of Zend_Controller_Request_Abstract, none given, called in /www/zf-tutorial/application/controllers/IndexController.php on line 6 and defined in /www/zf-tutorial/library/Zend/Controller/Action.php on line 92
    when run index.php

  105. 105 eugene

    About previous 104. There is no errors in the code. I just by mistake used latest (on that date) frame version that has a few changes that don't work with the example.
    This tutorial is a great work to introduce even experienced programmers to MVC framework. Keep going Rob!

  106. 106 Pooja

    Hello Rob

    i ahve been using ur tutorial as a base for my application

    I m quiete xcited about this

    I have a query .

    i have a controler file called ProjectDetailsControlled.php

    where in the indexAction function

    i have the follwoing code

    $config1 = new Zend_Config_Ini('../application/config.ini', 'general');
    Zend::register('config1', $config1);

    // setup database
    $newdb = Zend_Db::factory($config1->db->adapter, $config1->db->config->asArray());

    $select=new Zend_Db_Select($db);
    $select->from('projectproduct', 'projectproduct.projectproductid');
    $select->from('product', 'product.title as tt');
    $select->from('project','project.projectid');
    $select->where('project.projectid = ?', $id);
    $select->where('projectproduct.projectid = project.projectid');
    $select->where('projectproduct.productid = product.productid');
    //$result = $db->fetchRow($select);
    $result = $db->fetchAll($select);

    $view->result = $result;

    $view->actionTemplate = 'projectDetails.tpl.php';
    echo $view->render('site.tpl.php');

    Now in the projectDetails.tpl.php
    i have this code
    result as $rst) {
    echo $this->escape($rst['tt']);
    }?>

    The above query should return 3 records
    but i m not able to get the code working properly
    Can u pls tell how i can use the data from the above query in my projectDetails.tpl.php file

    Thnx
    Pooja

  107. 107 Pooja

    looks like i sorted it out

    It was some syntac errrr

    Thnx

  108. 108 Rob...

    Pooja,

    I'm glad you sorted it!

    Regards,

    Rob...

  109. 109 Abdou

    hey Rob,

    first i wanna thank you for this great tutorial, im totaly new to zend framework and your tutorial was a great help :)

    im using version 0.6.0 of zend framework, i had to make some changes to make it work.. still i have some problems:

    - the edit action wont work, i have a notice "Undefined property: IndexController::$_action..." and an error "Call to a member function getParams() on a non-object in..."

    - another problem is that only firefox can show the page, in IE i get a blank page.

    Thx

  110. 110 Rob...

    Hi Abdou,

    I've started working on a version of the tutorial for v0.6. You can see where I've got to by checking out the svn version at http://svn.akrabat.com/svn/zf-tutorial/trunk/

    Regards,

    Rob...

  111. 111 Abdou

    Hi Rob,

    The code is still not working, i took the editAction() from your svn version the error i get is the same :
    "Fatal error: Call to a member function getParam() on a non-object in..."
    plus, IE doesnt show anything.

    I guess i have to use earlier version of the framework, but if i had to, what are consequences ? does it have some bugs or security holes ?

  112. 112 Rob...

    Hi Abdou,

    Have you updated your index.php as per the svn version?

    Which line is the "Call to a member function getParam() on a non-object" error happening on?

    Regards,

    Rob...

  113. 113 Abdou

    Hi Rob,

    i just updated my index.php, the difference with yours is the router, i was using one (i wonder why you're not using it :) ), the error is still the same, and its happening on this line:

    "87 $id = (int)$this->_request->getParam('id', 0);"

    I commented the same line, and put a value for $id, ten i had the same error, but this time its about this line:

    "98 $this->_response->setBody($view->render('site.tpl.php'));"

    Error -> "Call to a member function setBody() on a non-object"

    Thx for help.

  114. 114 Rob...

    Hi Abdou,

    Did you change __construct() in your index controller to init() as in the svn file ?

    Regards,

    Rob...

  115. 115 Abdou

    Hi Rob,

    The problem is solved now :) i had to change the _construct() of course.

    Thank you a lot...

  116. 116 Rob...

    Great news Abdou!

    Regards,

    Rob...

  117. 117 Ricardo

    I have a problem:

    When I do http://localhost/zf/index/add everything is ok. But if I do http://localhost/zf/foo/add is not working (and I have the FooController.php file with the add method). It gives me the 404 error. Even if I define noRouteAction in the IndexController, it gives the same error.

    I have the site in sub-directory zf, and I have the setBaseUrl('/zf') in the controller.

    v0.6

    Can you help me?

    Ricardo

  118. 118 Riki Risnandar

    Great tutorial.. thanks :) it should be included in Zend Framework documents...
    this tutorial is clear and explain every detail in every line..

  119. 119 Riki Risnandar

    Ricardo, do you define the FooController in FooController.php like this one ?
    class FooController extends Zend_Controller_Action

  120. 120 Will Prater

    Should one use appendBody() vs setBody() since there could have been other headers, exceptions, etc. written from other parts of the application before hitting this controller?

  121. 121 Rob...

    Will,

    I suspect that it depends on your application as to whether any given controller action is "in charge" of the response enough to use setBody() in preference to appendBody(). Generally, that will depend on if you use plugins or _forward(). (At a guess, anyway!)

    Regards,

    Rob...

  122. 122 anthony

    please help me in this tutorial. im getting error 404 http://localhost/zf-tutorial1/index/add/ but when im in this page http://localhost/zf-tutorial1/ in work. what do you think i must do? thanks in advance..

  123. 123 Rob...

    Hi Anthony,

    Is your Apache set up correctly to read the .htaccess file? At a guess you haven't got the correct AllowOverride setting in your httpd.conf file.

    Regards,

    Rob...

  124. 124 thony

    Fatal error: Class 'Album' not found in C:\Program Files\xampp\htdocs\zf-tutorial\application\controllers\IndexController.php on line 13
    what would be the solution for this,please help. thanks

  125. 125 Rob...

    Thony,

    At a guess, you haven't set the path to your models/ directory correctly in index.php.

    Regards,

    Rob...

  126. 126 Kyle

    I just updated to 0.6 from 0.2 and had a bunch of errors I needed to fix. Mostly changing stuff in the view from if($view->error) to if(isset($view->error)) and so on, but I also needed to change how the router was setup so I came back to your site for the new tutorial and copied the new lines. These lines are:

    $baseUrl = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], '/index.php'));
    $frontController = Zend_Controller_Front::getInstance();
    $frontController->setBaseUrl($baseUrl);
    $frontController->setControllerDirectory('../app/controllers');
    $frontController->throwExceptions(true);

    Now though, I can't get any actions in IndexController to work. For example, site.com/test will not go to the action "test" in IndexController, but instead it will error and say that it can't find TestController.php. All I want to do is use noRouteAction in IndexController for a 404 page.

  127. 127 Kyle

    It would seem that I'm having the same problem as Ricardo and anthony.

  128. 128 Kyle

    Here's some more info.

    site.com/index goes to the IndexAction in IndexController
    site.com/index/test goes to the TestAction in IndexController
    site.com/index/foobar goes to the noRouteAction in IndexController

    site.com/ goes to the IndexAction in IndexController
    site.com/test says it can't find TestController.php
    site.com/foobar says it can't find FoobarController.php

  129. 129 Rob...

    Hi Kyle,

    The Dispatcher has changed in 0.6 and you need to write a front controller plugin to handle this situation.

    Regards,

    Rob...

  130. 130 Kyle

    It seems more like a bug to me than a feature I need to add back in myself.

  131. 131 Kyle

    While I'm sure Rob has seen it, there's an explanation of why it's this way now here: http://www.nabble.com/forum/ViewPost.jtp?post=7662411&framed=y&skin=16154

    Catching the exception and redirecting was what I had started to do anyway, and if it's good enough for Matt it's good enough for me.

  132. 132 Rob...

    Hi Kyle,

    I subscribe to the mailing list and was going to dig through my archives later to see what I could find. Thanks for finding it for me :)

    Regards,

    Rob...

  133. 133 Kyle

    I went with Matt's method to check if the route isDispatchable() which also stops it from erroring if the user tries to execute an action that is a private function. So better all round I think.

  134. 134 Kyle

    A couple questions:

    1) Since there's now init() to automatically execute stuff when a controller is started, is there a similar thing to automatically execute stuff afterwards?

    2) Is there a reason why I shouldn't be using __autoload or is it just not in your tutorial to keep it simple or PHP4 compliant?

    3) When you use the predefined methods to get data from a database, such as findAll(), fetchCol(), etc you get the data back like $table->field, but if you build your own methods with select() you get it back in an array like $table['field']. It's kind of irritating that I get my data in two different formats so is there a way to make these match? I assume it's something to do with Zend_Db_Table_Rowset.

    4) Would you consider doing some mini tutorials about using some basic stuff like cookies, sessions, etc? It took me 20 mins reading the manual to get all the information I needed to use cookies and I still don't know if I'm doing it properly. I could do them the old fashioned way but then I wouldn't be learning anything.

  135. 135 Rob...

    Hi,

    1) postDispatch() or __destruct(). Note that there is a preDispatch() too.

    2) nope - feel free to use __autoload if you want to :)

    3) I agree. Yeah it is to do with Zend_Db_Table_Rowset and is a right pain!

    4) Yeah, mini tutorials will come along when I get some spare time. I'm completely swamped at the moment though :(

    Regards,

    Rob...

  136. 136 Kyle

    So there's no solution to #3? The manual says that you will rarely need to call Zend_Db_Table_Rowset manually. So if it can be called manually then what can we do with it? Can it be used change the data before a model outputs it?

    Thanks for your tutorial though. I've been using it to get every version since 0.1.4 or earlier going. Sure it doesn't go into any depth but it gets you going and then you can google around for more complicated things.

  137. 137 Rob...

    Hi Kyle,

    At the moment, I iterate over the array and turn it into an array of stdClasses with the altered field names as would be used by Zend_Db_Table_Rowset. This is clearly not the right way to do it though!

    Regards,

    Rob...

  138. 138 mike

    I am on a shard hosting env. I have the pdo_mysql problem:

    Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The mysql driver is not currently installed' in /home/username/lib/Zend/Db/Adapter/Pdo/Abstract.php:88

    I have the following in my php.ini:

    extension=pdo.so
    extension=mysql.so
    extension=pdo_mysql.so
    magic_quotes_gpc = Off
    register_globals = off

  139. 139 Mile

    Oh, I forgot, here is the phpinfo() output:

    './configure' '--with-xml' '--enable-bcmath' '--enable-calendar' '--with-curl' '--with-dom' '--with-dom-xslt' '--with-dom-exslt' '--enable-exif' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--with-gettext' '--with-imap=/usr/local/imap-2004g' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-mcrypt' '--enable-memory-limit' '--with-mhash' '--enable-magic-quotes' '--with-mysqli' '--with-mysql=/usr' '--with-openssl' '--enable-discard-path' '--with-pear' '--enable-xslt' '--with-xslt-sablot' '--enable-sockets' '--enable-track-vars' '--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--enable-versioning' '--enable-wddx' '--with-xmlrpc' '--with-zlib' '--prefix=/usr/local/php5' '--exec-prefix=/usr/local/php5' '--program-suffix=5' '--enable-force-cgi-redirect' '--enable-discard-path'

  140. 140 Rob...

    Hi Mike,

    The problem is that your host has not enabled the PDO extension. You could try using the Zend_Db adapater for mysqli which is in the incubator.

    Regards,

    Rob...

  141. 141 ranza

    hi, thanks for the tutorial! - i was just wondering if there are a way to select from more tables. Lets say i have a table called albums, and one called artists. I have a modeler for both tables and i can select from both individual...

    But what i cant do is select from both at the same time like this,

    $albums = new album();
    $albums->fetchAll();
    $artists = new artist();
    $artists->fetchAll();

    - so lets say i want data from both i'll have to do it manual by using the database object and the select function

  142. 142 ranza

    wops, pushed before i was done writing :)

    but i was wondering if there are a way to get by this with the use of the modeler? i've been looking around and cant seem to find a solution to this. It seems like the pdo CAN do query's simultaneity but i dont know if the zend framework has the same features. I cant seem to find anything about it in the manual

  143. 143 jim

    i've been playing with this demo, on a windows box and linux. windows box path creation is messed up using the wrong slashes assuming linux. and then linux path creation is not working either.

    great framework

  144. 144 Rob...

    Ranza,

    You need a class that implements the ActiveRecord design pattern. Zend_Db_Table doesn't do this, so you either need to roll your own or work around it until something is added to the Zend Framework.

    As far as I remember, Bill Karwin is looking at the database components in the 0.8 time frame.

    Regards,

    Rob...

  145. 145 Rob...

    Jim,

    What do you mean by "Windows box path creation is messed up"? The tutorial specifically uses the PATH_SEPARATOR constant to ensure that it does work.

    If you mean directory separator, then PHP on Windows can understand that / is a directory separator just like \ is.

    Regards,

    Rob...

  146. 146 Sergio

    thank you for the tutorial
    Great work!

  147. 147 giorgio

    Hi Rob,

    problem at page 6 :
    I changed the .htaccess in C:\Programmi\Apache Software Foundation\Apache2.2\htdocs ( document root) this way:

    RewriteEngine on
    RewriteBase /zf_tutorial
    RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php
    php_flag magic_quotes_gpc off

    When I type http://localhost/ I can see the right page.
    When I type http://localhost/index/ I can see the right page.

    When I type http://localhost/index/add I see always " in IndexController::IndexAction()";

    It seems that (apache /ZF ) redirect to defalt index action.

    what the problem ?
    thanks giorgio

  148. 148 Marc

    Any future release of the tutorial for the 0.7.0 release of the ZendFramework?

  149. 149 Rob...

    Good point!

    I'm nearly sure that it works "as is" with 0.7, but I'd better test ;)

    Regards,

    Rob...

  150. 150 San

    Hi,
    Home page is loading fine. When i press on 'Add new album' link (http://localhost/zf-tutorial/index/add)
    "The page cannot be found" error page is coming

    ZF Version : 0.7

  151. 151 San

    Hi,
    After i copied 'Zend' folder and Zend.php to zf-tutorial\library\
    tutorial is working fine :-)

    thanks
    San.

  152. 152 Rob...

    Hi San,

    Glad to hear it!

    Regards,

    Rob...

  153. 153 Themis

    Hi Rob!

    I would like to extend the application and make a view page to each album.

    Offcource i use viewAction() and i make something like

    function viewAction() {
    $view =Zend::registry('view');
    $view->title = "view the doc";

    $doc = new Doc(); //i have change that,it's ok do not confuced
    $view->docs = $doc->fetchAll();

    $view->actionTemplate='indexView.tpl.php';
    $this->_response->setBody($view->render('site.tpl.php'));
    }

    and in the indexView.tpl.php i use
    escape($this->doc->name);?>

    byt it looks like that is not so simple and i take Notice: Undefined property: Zend_View::$doc in ...

    Can you help me a while?

    thanks!

  154. 154 Bagus

    hi Rob,

    I've been trying to use your tutorial and try to run it but why I always got this error :

    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message '"index.php" controller does not exist' in D:\project\oprekzend\library\Zend.php:229 Stack trace: #0 D:\project\oprekzend\library\Zend\Controller\Dispatcher.php(386): Zend::exception('Zend_Controller...', '"index.php" con...') #1 D:\project\oprekzend\library\Zend\Controller\Front.php(725): Zend_Controller_Dispatcher->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #2 D:\project\oprekzend\index.php(16): Zend_Controller_Front->dispatch() #3 {main} thrown in D:\project\oprekzend\library\Zend.php on line 229

    I'm using W2K with IIS and PHP 5.1.4

    thanks..

  155. 155 Rob...

    Hi Baugus,

    What's the URL that you are trying to access?

    Regards,

    Rob...

  156. 156 Bagus

    192.168.0.1/oprekzend/index.php

  157. 157 Rob...

    Bagus,

    I think that the base url is not being set to the correct value.

    Try adding:

    $frontController->setBaseUrl('/oprekzend');
    

    After:

    $frontController->throwExceptions(true);
    

    in index.php.

    Regards,

    Rob...

  158. 158 Bagus

    I finally use setBaseUrl('/oprekzend/index.php')
    and it's done..
    but now when accessing page :
    - http://192.168.0.1/zend/index/add,or
    - http://192.168.0.1/zend/index/edit, or
    - http://192.168.0.1/zend/index/delete

    show page cannot be display at my browser..

    I think this problem because I'm using IIS W2K ?

  159. 159 Rob...

    Hi Bagus,

    You now need to sort out ISAPI_Rewrite. There's more on the wiki at http://framework.zend.com/wiki/x/1Q.

    Alternatively, you should find that URLs of the form http://192.168.0.1/oprekzend/index.php?controller=index&action=edit should work.

    Regards,

    Rob...

  160. 160 glumac

    English version has incorrect link to old 1.2.2.

  161. 161 Rob...

    Thanks glumac!

    Fixed.

    Regards,

    Rob...

  162. 162 Ali

    Hi,
    First I would like to thank you for this great tutorial, may be the next step would be to include smarty and Ajax.
    Second, when I tried calling http://www.mysite.com/zend/index.php, I got an error IndexPHPControllerPHP not found. So I investigated the root cause and traced it in the dispatcher, what I did was adding this line:
    $frontController->getDispatcher()->setWordDelimiter('.php');
    before
    $frontController->throwExceptions(true);

    I am wondering if this is safe to do that in Framework 0.7. By the way the fix to this same problem mentioned in here http://framework.zend.com/issues/browse/ZF-835 didn't work for me.

    -Ali

  163. 163 Ali

    Rob,
    Can you please tell me why you didn't approve my posting?
    thanks,
    -Ali

  164. 164 Rob...

    Hi Ali,

    Probably because I pressed the wrong button! I've approved it now. Sorry!

    Regards,

    Rob...

  165. 165 christian

    I ran into this very weird error. When i deploy the website on my production server i get this error as if it looks for my index controller in some weird dir.

    ive tryed to set a basedir, give it absolute urls to the folders and so on. Do you have any idear of what causes this error?

    error:

    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message '"index" controller does not exist' in /home/frontier/library/Zend.php:229 Stack trace: #0 /home/frontier/library/Zend/Controller/Dispatcher.php(386): Zend::exception('Zend_Controller...', '"index" control...') #1 /home/frontier/library/Zend/Controller/Front.php(725): Zend_Controller_Dispatcher->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #2 /home/frontier/public_html/index.php(43): Zend_Controller_Front->dispatch() #3 {main} thrown in /home/frontier/library/Zend.php on line 229

    my index.php: http://pastebin.dk/index.php?show=3054

  166. 166 Johannes

    Great work. Looking forward to a 0.8 update ;-)

  167. 167 Glen

    ok, for ZF 0.8 :
    (It's not a bug, it's a feature)! Zend_Controller_RewriteRouter was renamed to Zend_Controller_Router_Rewrite.

  168. 168 Rob...

    Glen,

    Where do I use Zend_Controller_RewriteRouter in the tutorial?

    Regards,

    Rob...

  169. 169 Rob...

    christian,

    Missing indexController.php or permissions problem?

    Regards,

    Rob...

  170. 170 christian

    ah i found the problem. the controller looks for IndexController.php, not indexController.php :) - i coded the thing on my macbook and apache isnt case sensitive. My production server is a linux which IS case sensitive :)

    kinda bad mistake sorry!

  171. 171 Rob...

    Christian,

    ah! done that too :(

    Regards,

    Rob...

  172. 172 Alan

    Just went through the tutorial, very clear. Thanks.

    Unfortunately I downloaded a nightly snapshot rather than 0.8 and the Zend_Filter_Input class has been deprecated (and removed from the source tree) eight days ago.

    I cannot find any documentation on how the replacement solution should be implemented, but thought you should know. If you find anything, I'd appreciate a response too!

    Thanks

    Alan

  173. 173 Rob...

    Alan,

    You can use $_POST directly in the action functions and remove all reference to Zend_Filter_Input in the index.php.

    Have a look at Zend_Validate to do the validation bits. It's not static, so you have to create an instance of the Zend_Validate_XXX class first and then call it's check() method.

    Hope that gives you some pointers.

    Regards,

    Rob...

  174. 174 John

    0.9.0 has affected the tutorial as components are deprecated. So far Zend::loadClass (index.php lines 10-15)
    Zend_Filter_Input (index.php line 15)
    Zend::register (index.php lines 18-19).

    I keep referring back to this tutorial because it work so well. Thanks for keeping up with it.

  175. 175 John

    And then I find this article... doh!

    http://akrabat.com/2007/03/10/goodbye-zendphp/

    Once again, thanks for all your work and help.

  176. 176 Rob...

    Hi John,

    New version of the tutorial is in the works :)

    The latest SVN version of the tutorial code at http://svn.akrabat.com/svn/zf-tutorial/trunk/ works with 0.9 after you fix the typo in Zend/Db/Table/Row/Abstract.php.

    Regards,

    Rob...

  177. 177 José de Menezes

    Hi Rob,

    I tried to use your tutorial, but my ZF is 0.9.0 and it not worked...

    What can I do to make it works??

    Regards,

    José

  178. 178 Zuhair Naqvi

    How bout 0.9.0 Beta MVC tutorial?

  179. 179 Stuart

    Look up just above your comments to #176, guys. He is working on a 0.9.0 version and it will be out shortly.

  180. 180 José de Menezes

    Hi, I downloaded version 0.8.0 and at the IndexAdd action, the follow error occurs:

    Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent' in D:\www\projeto\lib\Zend\Controller\Response\Abstract.php:240 Stack trace: #0 D:\www\projeto\lib\Zend\Controller\Response\Abstract.php(125): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 D:\www\projeto\lib\Zend\Controller\Action.php(607): Zend_Controller_Response_Abstract->setRedirect('/projeto/', 302) #2 D:\www\projeto\application\controllers\IndexController.php(45): Zend_Controller_Action->_redirect('/') #3 D:\www\projeto\lib\Zend\Controller\Action.php(392): IndexController->addAction() #4 D:\www\projeto\lib\Zend\Controller\Dispatcher\Standard.php(211): Zend_Controller_Action->dispatch('addAction') #5 D:\www\projeto\lib\Zend\Controller\Front.php(750): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #6 D:\www\projeto\index.php(44): Zend_Controller_Front->dispatch() #7 {main} thrown in D:\www\projeto\lib\Zend\Controller\Response\Abstract.php on line 240

    I think its because line "$this->_redirect('/');" but I don't know how to fix it...

  181. 181 José de Menezes

    How to get the source code??? how to use these SVN stuff?

  182. 182 Scott

    I was getting the error:
    Uncaught exception 'Zend_View_Exception' with message 'script 'index/index.phtml' not found in path' in /Volumes/Storage/SYSTEM/wwwroot/zend/library/Zend/View/Abstract.php:594

    until I changed the line
    $view->setScriptPath(realpath('./application/views'));

    to

    $view->setScriptPath(realpath('./application/views/scripts'));

    when trying to use your 26th revision in your zf-tutoiral with zend framework 0.9.0 ... should I not had to have done this?

  183. 183 Stuart

    Jose, first get a copy of subversion (svn). You can get Rob's latest code with the command:

    svn co http://svn.akrabat.com/svn/zf-tutorial/branches/1.2/

  184. 184 Rob...

    Scott,

    It's a bug in revision 26. We don't need to create the view in the bootstrap any more. Revision 27 fixes it.

    Regards,

    Rob...

  185. 185 Brian

    Can't download rev27 or perhaps don't know how to use svn.
    I'm having a lot of problems with include path. I had to set up a separate path file to require_once each class file, for some reason I can't include the entire dir. Also having the same problem with Abstract.php (post 182), but I don't know how to fix (adding 'scripts' didn't work).

  186. 186 Scott

    Rob,

    Thanks for the response, I checked out Rev 27 and that worked without modification...actually, that is not true. I had the same problem as Matt in setting the include path...I used his include_path that he showed in post 69 (I am running a MAMP setup in OSX, just so you know). This is a great tutorial and trying to fix bugs is what makes me understand the framework that much better, thanks for your hard work!

  187. 187 Rob...

    Scott,

    Great - I'm glad 27 fixed that one!.

    With any luck 28 fixes the include path issue.

    Regards,

    Rob...

  188. 188 John

    Just downloaded version 1.3.0
    After adjusting pathing to match my need to store things outside the root, it works perfectly. Took all of 10 minutes.

    Now to see if I can break (err) use it again as a study guide. :-)

    Once more... Thanks loads.

  189. 189 rob

    The best Tutorial. This should be included in zend as the official tutorial.

  190. 190 John Lawson

    Great tutorial!
    I would like to report a minor typo - the hyperlink at the top of page 5 refers to http://localhost/zf_tutorial/
    instead of
    http://localhost/zf-tutorial/

    Regards

  191. 191 Pieter

    At first I couldn't get the delete functionality to work. Already thought it was strange the tutorial referred to a zf-tutorial/application/views/indexDelete.tpl.phpp template, which doesn't seem to fit in with the rest of the structure.

    It worked as soon as I applied the changes in the delete template that was made before, located at zf-tutorial/application/views/scripts/index/delete.phtml.

  192. 192 Jeff

    I too am getting the same error as Jose #180 - I too think it has something to do with the $this->_redirect('/');

    Can't send headers error.

    Looking forward to a solution.

  193. 193 Rob...

    Jeff,

    Headers already sent issues are usually related to echoing out something before the call to _redirect().

    Out of interest, do you have a closing ?> followed by a couple of blank lines anywhere?

    Regards,

    Rob...

  194. 194 Jeff

    Hi Rob

    Thanks for getting back to me so quickly - no, no closing ?> and no blank lines anywhere.

    It just stops at the redirect, I can echo something out right before but not before the 'return;'

    I've copied the code below:

    Cheers
    Jeff

    public function editusersAction()
    {
    $this->view->pageTitle = 'edit this users';
    $this->view->section = '';
    $this->view->setCSS = '';
    $this->view->action = 'edit';
    $this->view->button = 'update';
    $this->view->userTypeLabel = 'you are a';
    $this->view->users = new stdClass();

    $db = Zend_Registry::get('dbAdapter');
    // set up null values
    $id = $this->getRequest()->getParam('id');
    $sql = $db->select();
    $sql->from('users', '*');
    $sql->where('users.id =?', $id);
    $this->view->users = $db->fetchRow($sql);

    $userTypeSql = $db->select();
    $userTypeSql->from('user_types', '*');
    $this->view->userTypes = $db->fetchAll($userTypeSql);

    if ($this->getRequest()->isPost()) {
    Zend_Loader::loadClass('Zend_Filter_StripTags');
    $filter = new Zend_Filter_StripTags();
    // set the post variables
    $now = date('Y-m-d H:i:s');
    $id = (int)$this->_request->getPost('id');
    $user_type_id = trim($filter->filter($this->_request->getPost('user_type_id')));
    $username = trim($filter->filter($this->_request->getPost('username')));
    $password = trim($filter->filter($this->_request->getPost('password')));
    $email = trim($filter->filter($this->_request->getPost('email')));
    $verified = trim($filter->filter($this->_request->getPost('verified')));
    $last_updated = $now;
    $deleted = trim($filter->filter($this->_request->getPost('deleted')));
    $preferred_name = trim($filter->filter($this->_request->getPost('preferred_name')));

    $data = array(
    'user_type_id'=>$user_type_id,
    'username'=>$username,
    'password'=>$password,
    'email'=>$email,
    'verified'=>$verified,
    'last_updated'=>$now,
    'deleted'=>$deleted,
    'preferred_name'=>$preferred_name,
    );
    $table = 'users';
    $where = $db->quoteInto('id = ?', $id);
    $db->update($table, $data, $where);
    $this->_redirect('/');
    return;
    }
    $this->render();
    }

  195. 195 Jeff

    Hi Rob

    just to add aomething else to the mix - it happens on the delete as well, and there's nothing in that one at all.

    public function deleteusersAction()
    {
    $db = Zend_Registry::get('dbAdapter');
    $id = $this->getRequest()->getParam('id');
    $table = 'users';
    $where = $db->quoteInto('id = ?', $id);
    $rows_affected = $db->delete($table, $where);
    $this->_redirect('/');
    }

    am I totally missing something?

    Jeff

  196. 196 GX

    Thanks Rob! Superb tutorial that's easy to follow. Cheers.

  197. 197 Brian

    Thanks for tutorial and to all who are posting solutions to various problems, it's been very helpful.
    in resolving the include issue, and conroller issues. I am now working wih tutorial v1.3.1 and ZF v0.9.1 and have run into a problem with the view template pages (.phtml). When I send the controller request it goes to the view template (add.phtml, etc.), but doesn't parse the php. Any suggestions?

  198. 198 Rob...

    Brian,

    Is your Apache set up to use .phtml as a PHP file?

    Regards,

    Rob...

  199. 199 Rob...

    Jeff,

    It's almost certainly in another file, or at the top of the controller file.

    Do you have the same problem with the zip file download?

    Regards,

    Rob...

  200. 200 Brian

    Rob,
    Thanks for the reply. I added
    AddType application/x-httpd-php .php .php3 .phtml

    to my httpd.conf, but same result: Page is blank; view source: html is visible, php is not visible on source or on browser display (perhaps the fact that it is not visible in source means it is being parsed, just not correctly).

  201. 201 Jeff

    Hi Rob

    Just to let you know - I found the problem, it was 1 extra line of space before my opening

  202. 202 Brian

    Rob,
    A little syntax error was the culprit, thanks for the assistance.

    This may not be the best place, but does anyone know the status of the forum? I registered, but account hasn't been activated and I don't get any responses from admins.

    Keep up the great work it is much appreciated!

  203. 203 John Baldock

    Thanks for the tutorial, it has been extremely useful!

    One thing I could have used though is some more info about avoiding SQL injection. For instance on page 16 you cast the getPost('id') as an int thus making it safe, but because of that you didn't use something like $table->getAdapter()->quoteInto('id = ?', $id) which, for me, would have been more helpful.

    From what I can tell you don't need to worry about escaping data that you insert using methods like $table->insert($data), but you do need to worry about escaping data used in the 'where' clause which is where quoteInto comes into play. Before using the Zend Framework I used Mysqli with prepared statements so I am a bit paranoid about becoming vulnerable to them again. ;)

  204. 204 Rob...

    John,

    You shouldn't use quote into for Integer database fields as it's incorrect SQL and many database engines will disallow it. That's why I used the cast to int.

    As you've noticed, insert()/update() automatically quote, but the where clause doesn't. It's just one of those things you have to learn as far as I can see.

    Having said that, if you pass in an array as the $where, it will quote. e.g:

    $r $table->fetchAll(array('date > ?''2002-02-02'))
    

    Regards,

    Rob...

  205. 205 John Baldock

    Thanks for the reply,

    I'll look into passing the where clause as an array, it looks useful.

    As far as I can tell it is safe to pass quoteInto() an int as it tests if it is an int before quoting (Zend_Db_Adapter_Abstract, line 440). I don't want to imply that casting the id as an int is a bad thing to do, it just would have helped me personally to have it explained. :)

    Cheers,
    John

  206. 206 Ven

    Hello Rob,
    thank you for the great tutorial!

    I have a problem with the example application - cd collection.

    The index list is displayed correctly. When I click at the "Edit" link, the form is populated with the artist name and title. Well, when I press the "Update" button, I got an error message at the both input fields:

    Notice: Trying to get property of non-object in C:\Program Files\xampp\htdocs\zf-tutorial\application\views\scripts\index\_form.phtml on line 5

    Notice: Trying to get property of non-object in C:\Program Files\xampp\htdocs\zf-tutorial\application\views\scripts\index\_form.phtml on line 10

    Also, when I try to delete a record and press the "Yes" button, the record is not deleted!

    When I try to add a new album, nothing happends - the form just reload.

    It seems that

    $this->_request->getPost('artist')

    return an empty value.

  207. 207 Ven

    Actualy it seems to have a problem with "localhost". When I try to load the website via localhost/zf-tutorial it does not works correctly. When I try to access via real ip address, even via 127.0.0.1 - it works!

  208. 208 Rob...

    Ven,

    Possibly related to xampp? I have no idea though!

    Regards,

    Rob...

  209. 209 Russell

    Just hoping for a bit of help. With the current stable beta (0.9.2) and tutorial 1.3.3, having only done all the .htaccess files and index.php, I get:

    [08-Apr-2007 10:34:33] PHP Fatal error: Cannot access protected property Zend_Controller_Front::$_instance in /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Front.php on line 147

    If I use the current snapshot instead, it works as expected (complaining about 'Invalid controller specified (index)'). But then when I go and make application/controllers/IndexController.php, it goes back to the same message as before,

    PHP Fatal error: Cannot access protected property Zend_Controller_Front::$_instance in /Applications/MAMP/htdocs/zf-tutorial/library/Zend/Controller/Front.php on line 147

    I don't get a stack trace to work with either.

    Any suggestions?

    php 5.2.0
    Apache 2.0.59

  210. 210 Russell

    Never mind... found out "MAMP" (Mac AMP package) had eAccelerator and Zend Optimizer running by default. Killed them and it's all good.

    Thanks for the great tutorial.

  211. 211 Remi

    Thank you for your great tutorial!

    I have a short question: I'm a little bit unsure about the right syntax. Your class "Album" extends from "Zend_Db_Table", but the Reference Manual from Zend extends from "Zend_Db_Table_Abstract". Is there a difference? If not, what is the recommended way?

  212. 212 Remi

    Found the answer by myself:
    Using of Zend_Db_Table is deprecated since V 0.9 of the Zend Framework. The Reference Manual from Zend is correct. I will use Zend_Db_Table_Abstract in my projects.

  213. 213 Matt

    Why don't you use
    require_once 'Zend/Loader.php';
    Zend_Loader::registerAutoload();

    It is far easier then using
    Zend_Loader::loadClass('Zend_Controller_Front');
    Zend_Loader::loadClass('Zend_Registry');
    Zend_Loader::loadClass('Zend_View');
    ...
    ...

  214. 214 Guy

    Guys,

    I've been trying to get the other controller other than IndexController to work, but to no avail.

    http://localhost/zf-tutorial/index -> ok
    http://localhost/zf-tutorial/register -> 404 error

    The directory layout looks like:
    - application/controllers
    -- IndexController.php
    -- RegisterController.php

    Any help is really appreciated.

    /Guy

  215. 215 Jens Christian

    I had som problems with the .htaccess file. I got internal servererrors, or got redirected to wrong directorys. The following worked for me:

    RewriteEngine On
    RewriteRule ^.+$ /zf-tutorial/

  216. 216 Rob...

    Remi,

    As you've noticed, Zend_Db_Table_Abstract is the correct way to do it. My use of Zend_Db_Table is an oversight when I updated to the new ways of doing things.

    Regards,

    Rob...

  217. 217 Rob...

    Matt,

    It saved having to explain autoload :)

    Guy,
    Your Apache isn't reading your .htaccess file. Ensure that you have AllowOveride All set in your httpd.conf.

    Regards,

    Rob...

  218. 218 nour

    Hallo Rob, I try to inisalize een class but it dont work:
    $shippingmethods = new ShippingmethodsController();
    $shippingmethods->indexAction

    -----------------

        function indexAction()
        {
            if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
                Zend_Loader::loadClass('Zend_Filter_StripTags');
                $filter = new Zend_Filter_StripTags();
                //$post = Zend::registry('post');
                 $_SESSION['shippingmethodid'] = trim($filter->filter($this->_request->getPost('shippingmethod')));
    	 					 $this->view->shippingmethodid = $_SESSION['shippingmethodid'];
          	}
          	if (!empty ($_SESSION['shippingmethodid'])){$this->view->shippingmethodid = $_SESSION['shippingmethodid'];}
    
          	//$this->view->cartactionTemplate = 'showBigCartIndex.tpl.php';
          	//$this->render();
    
          	$shippingmethods = new ShippingmethodsController();
            $shippingmethods->indexAction();
          	$this->loadCartAction();
    
          	$this->render();
    
        }
    

    ----------------
    thanks

  219. 219 Rob...

    nour,

    More information than "it dont work" would be useful...

    Regards,

    Rob...

  220. 220 nour

    hai rob, i want to initialize ShippingmethodsController() within
    CartController but i get this error :
    Fatal error: Argument 1 passed to Zend_Controller_Action::__construct() must be an object of class Zend_Controller_Request_Abstract, called in
    ==============
    initView();
    $this->view->baseUrl = $this->_request->getBaseUrl();
    }
    function indexAction()
    {
    $shippingmethods = new ShippingmethodsController();
    $shippingmethods->indexAction();
    $this->render();

    }
    }

  221. 221 Rob...

    Nour,

    What is the initial definition of class ShippingmethodsController() ?

    Regards,

    Rob...

  222. 222 nour

    thanks for your hulp

    this is the ShippingmethodsController
    =================

    initView();
    Zend_Loader::loadClass('Shippingmethods');
    $this->view->baseUrl = $this->_request->getBaseUrl();

    }

    function indexAction()
    {
    $Shippingmethods = new Shippingmethods();
    $order = 'shippingname';
    $rowset = $Shippingmethods->fetchAll(null, $order);
    $this->view->Shippingmethods = $rowset;
    }

    }

  223. 223 DJIO

    Man, this is impressive!

    Excelent writting and aproach of teaching.

    2 thumbs up!

  224. 224 nour

    hai rob i m waiting for your hulp

  225. 225 Rob...

    DJIO,

    Thanks :)

    Regards,

    Rob...

  226. 226 Rob...

    nour,

    Is ShippingmethodsController extending Zend_Controller_Action?

    Regards,

    Rob...

  227. 227 nour

    thanks Rob,
    Yes
    =============
    initView();
    Zend_Loader::loadClass('Shippingmethods');
    $this->view->baseUrl = $this->_request->getBaseUrl();
    }

    function indexAction()
    {
    $Shippingmethods = new Shippingmethods();
    $order = 'shippingname';
    $rowset = $Shippingmethods->fetchAll(null, $order);
    $this->view->Shippingmethods = $rowset;
    }

    }

  228. 228 nour

    Yes this is is:
    class ShippingmethodsController extends Zend_Controller_Action
    {
    }

  229. 229 Rushy2uk

    Hi Rob,

    Firstly, I'd like to thank you for your hard work putting this comprehensive tutorial together. It's easily the best one I've read, and I've been looking for the "right way" to use the framework for a while.

    I'm tryin to use your example with a SQLITE2 database. I've created a sqlite2 database called zftest.db, and the config file now looks like this:

    [general]
    db.adapter = PDO_SQLITE
    db.config.dbname = zftest.db
    db.config.sqlite2 = TRUE

    I'm not sure where the actual database file should go in the structure, so I've put it in every folder to test, but no joy :(

    Could you help with this please?

  230. 230 Rob...

    Rushy2uk,

    I'd guess that it needs to be in the root directory. Alternatively, I'd try a fully qualified path as the dbname field.

    Regards,

    Rob...

  231. 231 Rushy2uk

    Thanks Rob, I'll try again later.
    I also read it's possible to use the mysqli adapter with Zend_Db, put I can't find any information on this.

    Can you point me in the right direction please? (I'm keen to finish your tutorial, but my host doesn't support PDO_MYSQL, only PDO_SQLITE and MySQLi)

  232. 232 Rushy2uk

    No joy this evening with the PDO_SQLITE or MySQLi.

    Has anyone managed to get those adapters working with your tutorial?

  233. 233 Rushy2uk

    I stayed up until 01:00 last night, and managed to get your tutorial working with the MYSQLI adapter (Zend_Db), but still couldn't get SQLITE working.

    In the ZF manual, it says I should use the "dbname" and "dsnprefix" PDO options like this:

    [general]
    db.adapter = PDO_SQLITE
    db.config.dbname = zftest.sq2
    db.config.dsnprefix = sqlite2

    I'd really like to get your tutorial working with SQLite too, but a blank screen is displayed when I use the above .ini file.

    Could you verify that it's possible to use SQLite with your tutorial please? (so I don't go insane!)

    Thanks again for teaching me the "right way" of using the ZF.

  234. 234 Rob...

    Hi Rushy2uk,

    I'm a little snowed under with day-job work at the moment, but when I get some free time, I'll have a look at SQLite.

    Regards,

    Rob...

  235. 235 Stuart

    Great tutorial! Thanks so much for producing it.
    I'm trying out variations of things with your tutorial. One area I have a problem is when trying to do a distinct select in Zend_Db_Table. The manual shows how to do it with Zend_Db_Select but how would I do it using Zend_Db_Table?

  236. 236 jude

    I have tried to adapt your tutorial to build a news site. I wish to add a "readon" to each news "intro" on the frontpage. That requires controller/view code to render one row only. I have tried to extend your controller/view code, but the view does not render. I feel that "foreach" must be ditched in favour of "for" in the view file.Cannot write the correct code. Any suggestions?

  237. 237 nour

    Hai Rob, wat is the Zend_Auth namespace, and How can i acces to its data. is it 'Zend_Auth'. can i do so: $authSpaceAccessor1 = new Zend_Session_Namespace('Zend_Auth');

  238. 238 nour

    Hai Rob, can i place this in my Bootstrap file I want to acces session data in all controllers
    =============== $user = Zend_Auth::getInstance()->getIdentity();
    echo $user->customerslastname;

  239. 239 Rob...

    nour,

    No idea bout what namespace Zend_Auth uses.

    You could certainly place your getIdentity call in the bootstrap though.

    Regards,

    Rob...

  240. 240 Rob...

    Jude,

    I am sure that using a for loop rather than a foreach will not make any difference.

    Regards,

    Rob...

  241. 241 Nick Howell

    Just wanted to say thanks for the great tutorial. A few things ran me around in circles for a bit, but all in all, awesome! Thanks!

  242. 242 miguelp

    i'm following this tutorial for the first time, and i'm running apache2.2 in a windows box. i, have made one simple change to what the tutorial says, instead of using a subfolder in the root called zf-tutorial, i used a subfolder called "prazer", i think this is not a big dial, anyway i came to a little problem at page 6, if i use the URL http://localhost/prazer/ it shows me "in IndexController::indexAction()" as it should but if i add the "index/add" to the URL like this "http://localhost/prazer/index/add" it gives me an 404 error it seems like the URI component is not doing what it should be. Did i missconfigured something? what can be the problem in this case?

  243. 243 Rob...

    Nick,

    Thanks for your kind words. I'm glad it helped you.

    Regards,

    Rob...

  244. 244 Rob...

    miguelp,

    Check that you have AllowOverride All set in your httpd.conf file.

    Regards,

    Rob...

  245. 245 miguelp

    Rob, Thank problem solved.
    I have changed that but just on "
    Options FollowSymLinks
    AllowOverride All ..." forgot to check for more... Beginners misstake.
    This kind of things are new to me is the first time i set up a server by hand, till now i have been using server packs like Wamp or Xampp. Many thanks.

  246. 246 Oddish

    When I run the code on page 3 in your tutorial, I get this:

    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (index)' in C:\Apache\htdocs\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php:173 Stack trace: #0 C:\Apache\htdocs\zf-tutorial\library\Zend\Controller\Front.php(753): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:\Apache\htdocs\zf-tutorial\index.php(15): Zend_Controller_Front->dispatch() #2 {main} thrown in C:\Apache\htdocs\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php on line 173

  247. 247 Luke

    Rushy2uk,

    I was able to do the tutorial using SQLite with the following config.ini:

    [general]
    db.adapter = PDO_SQLITE
    db.config.host = localhost
    db.config.username = zftut
    db.config.password = zftut
    db.config.dbname = library/zftutorial.sqlite

    And the zftutorial.sqlite file is in just in my library dir. What specific error do you see?

    Also, for everyone, I wrote up my own tutorial on adding unit-tests to ZF controllers, if anyone is interested.

    http://tulsaphp.net/?q=node/40

  248. 248 Rob...

    Luke,

    Interesting.

    Thanks!

    Rob...

  249. 249 Rushy2uk

    Luke,

    I'll try your SQLite settings out tonight.

    Thanx in advance.

    Rushy

  250. 250 Rushy2uk

    Luke,

    What version of SQLite did you get working?

    It looks like you're using SQLite 3.
    I have to get it working on SQLite 2.
    Have you managed that too?

    Also, I thought you didn't need a username and password with SQLite?

    Rushy

  251. 251 Waigani

    I got stuck on page six for half a day until I realised apache was ignoring .htaccess files. I had to change AlloverrideAll in httpd.conf before I had any luck.

    Can I suggest putting a note in the tut to check that .htaccess is working.

    Cheers,

  252. 252 Edakos

    And the spanish version, mi hermano?

  253. 253 Waigani

    Sorry, typo above. Should be: AllowOverride All.

    I'm also stuck on pg 14 with the SQLite issue: I only have sqlite2 and sqlite pdo drivers.

    I've got an XAMPP setup on mac 10.4 and can't work out how to install PDO_mysql?

    Are there any simple instructions to do this? They would be very much appreciated.

    Cheers,

  254. 254 prebugged

    For those that are using WAMP5, you may encounter an error when testing the architecture out for the first time. I tried manually changing the php.ini to include the php_pdo_mysql.dll extension, but it didn't work. Its absence can be fixed via the WAMP icon in the system tray.

    Left-click the icon, go to PHP Extensions, and select php_pdo_mysql, then open the menu up again and Refresh it. It should be there, and your localhost/zf-tutorial will display correctly.

  255. 255 Rob...

    Thanks for the tip, prebugged!

    Regards,

    Rob...

  256. 256 Aras

    Hi prebugged..
    I had same prob. In wamp there is 2 php.ini files.
    wamp\Apache2\bin\php.ini and
    wamp\php\php.ini
    you have make the changes in
    apache2\bin\php.ini
    Regards.

  257. 257 Stig Benning

    Thank you for an excellent tutorial.

    I have most of it up and running in an afternoon even though I am totally new to the Zend Framework.

    Thumbs up!

    Stig

  258. 258 Rob...

    Thanks for your kind words Stig. I'm glad you found it useful.

    Regards,

    Rob...

  259. 259 Stig Benning

    Hi Rob. I am glad I said most of it and not all. The edit and delete I can not get to work. Adding albums works fine.

    Details: WinXP with Apache Server 2.2.4 on port 8080. Zend Framework 0.9.3 beta. Php version 5.2.2.2. MySql version 5.0.

    When pressing edit from index.php, I get somewhat the same error as in #206. The first text field displays:

    Notice: Trying to get property of non-object in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf-tutorial\application\views\scripts\Index\_form.phtml on line 5.

    In text field 2 the message is the same but with the line number 10.

    The code at line 5:

    escape(trim($this->album->artist));?>"/>

    The error message is displayed along with b and br tags.

    When clicking the delete link all that happens is that the page is refreshed and nothing deleted.

    I use the code from your revision 48, stage 2.

    Do you have any idea what causes this?

    Regards,

    Stig

    PS. In #176 you write "...after you fix the typo in Zend/Db/Table/Row/Abstract.php".

    What is the typo?

  260. 260 Stig Benning

    Ups! Somehow you did not get all the code at: The code at line 5, but the code is identical to yours in _form.phtml.

    Stig

  261. 261 Stig Benning

    Ups again: I found the answer to my PS question in one of your earlier posts. Thanks. It is fixed in the 0.9.3 version.

  262. 262 Rob...

    Hi Stig,

    It sounds like album hasn't been assigned to the view from the controller action.

    Regards,

    Rob...

  263. 263 Stig Benning

    Hi Rob,

    It may be that the code isn't correct, but as far as I can see it is identical to yours. editAction, deleteAction, and _form.phtml is displayed here:

    http://www.benning.dk/zf-tutorial/

    Thanks for your quick replies :)

    Stig

  264. 264 Stig Benning

    Hi Rob,
    I found out what the problem is. It is located 10 inches in front of screen :)

    In your index.phtml, you have a slash after id in the edit and delete parameters. I didn't. Adding the slash solved the problem.

    Amazing. Thank you, man!

  265. 265 Rob...

    Stig,

    Glad you sorted it!

    Regards,

    Rob...

  266. 266 Johnny

    I'm facing a problem where localhost/zf_test/index/index/ and localhost/zf_test/index/test/ works, but localhost/zf_test/test/index/ and localhost/zf_test/test/test/ generates 404 File Not Found error.

    I'm using ZF 0.9.3 beta on Windows XP with Apache

    The following is my .htaccess content:
    RewriteEngine on

    RewriteOptions Inherit
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (.*) index.php?apache_path=$1 [L,QSA]

    and my index.php is

    setBaseUrl( "/axchange/" );
    $frontController->run('./controllers');

    I have

    IndexController.php and TestController.php in my ./controllers folder

    Can anybody help me to solve this prob.

    Thanks in advance

  267. 267 Johnny

    Sorry, my index.php content is

    Zend_Loader::loadClass( "Zend_Controller_Front" );

    $frontController = Zend_Controller_Front::getInstance();
    $frontController->setBaseUrl( "/zf_test/" );
    $frontController->run('./controllers');

    if I use _forward("index", "test" ) inside the IndexController.php, it will call the TestController.php functions. But not directly from the url test/index/ calling.

  268. 268 Stig Benning

    Hi Rob

    Since I find the quality of your work excellent I would like to make a Danish translation. How to proceed?

    Best regards,
    Stig

  269. 269 Rob...

    Johnny,

    Is your local .htaccess file being used and have you enabled mod_rewrite in httpd.conf?

    Regards,

    Rob...

  270. 270 Johnny

    Hi Rob,

    I had un-commented the following 2 lines in my httpd.conf

    LoadModule rewrite_module modules/mod_rewrite.so
    AddModule mod_rewrite.c

    Is there somethings else I need to do to enable the mod_rewrite? Previously they are commented. Is there other way to detech whether the .htaccess is being used?

    Thanks Rob

  271. 271 Stig Benning

    Hi Rob,

    Is there a way to catch exceptions for non existing urls?

    If I i.e. try to access a non existing folder, say scripts, from the browser address line, I get this error message: Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (scripts)

    Would it be possible to re-route to index.php when an invalid url is received?

    Thanks, Stig.

  272. 272 Stig Benning

    index.phtml of course

  273. 273 Stig Benning

    Hi Rob,

    I found the answer. It has to do with me setting the base url. I have to set it as "http://localhost/sitename"

    then a faulty url is redirected to index.phtml

    Stig

  274. 274 Ravi

    Great tutorial Rob, I am new to PHP and Zend. Just tried with your tutorial and it is very interesting.
    Sample application is up and running.
    Thanks.

  275. 275 Johnny

    Hi Rob,

    Finally I had figured out the .htaccess is not being used even when I enabled the mod_rewrite

    I find out that the httpd.conf defaulted to

    Options FollowSymLinks
    AllowOverride None

    which disregard all the .htaccess to be used. So I changed it to

    Options FollowSymLinks
    AllowOverride All

    and the Zend_Control magic works.

    Thanks for pointing me to the right direction.

  276. 276 Rob...

    Ravi,

    Thank you for your kind words. I'm glad you've got it going.

    Regards,

    Rob...

  277. 277 Rob...

    Johnny,

    Glad you sorted it!

    Regards,

    Rob...

  278. 278 Jens

    Hi,

    How do I use custom helpers in your example?

  279. 279 Nate

    Great tutorial!

    Small spelling mistake on page 5 (version 1.3.4) ... it's "Organizing", not "Organising".

  280. 280 Rob...

    Nate,

    I'm British...

    Regards,

    Rob...

  281. 281 Andrew Taylor

    Thanks for continuing this excellent tutorial. I've currently got a system with a number of different actions, each action works with the same type of data and as a result, the view needed is always the same. I currently have 8 different views, which all are exactly the same. Is there a simple way to define the view that should be used for an action? This way I could define one view to be used with my actions. I realise I could create one file and then 8 views which reference the one (like you do with header and footer) but it would be easier if I could loose the files altogether.

    Thanks

    Andrew

  282. 282 Rene L.

    @Andrew
    Just try the new ViewRenderer:
    http://devzone.zend.com/node/view/id/2072

  283. 283 Rob...

    Yes. I need to update the tutorial to handle the new ViewRenderer action helper.

    Just need to find some time!

    Regards,

    Rob...

  284. 284 jude

    Hi Rob

    My code for trying to retain the tag does not work.

    Zend_Loader::loadClass('Zend_Filter_StripTags');
    $filter = new Zend_Filter_StripTags();
    $tagsAllowed = 'p';//or''
    $this->setTagsAllowed($tagsAllowed);

    Any suggestions?

  285. 285 Jordan

    Getting this error with the tutorial (v1.3.4):

    Zend_View_Exception: helper 'escape_string' not found in path in C:\Program Files\xampp\htdocs\zf_tutorial\library\Zend\View\Abstract.php on line 1000

    Up to this point in the tutorial (page 7 "Setting up the View"), everything was fine.

    Using ZF RC 1.0 with xampp 5.2, php 5.2

  286. 286 Rob...

    Jordan,

    I'm not totally surprised as 1.0RC introduced a few changes.

    Regards,

    Rob...

  287. 287 Rob...

    Jordan,

    I take it back - that error is something else. You should have

    $this->escape()
    

    not

    $this->escape_string()
    

    in your .phtml files.

    Regards,

    Rob...

  288. 288 Chris B

    Rob, thanks for not only writing a tutorial, but more importantly keeping it up to date as the Framework changes throughout time.

    It's the only one I've come across that's got me sufficiently started - I just need to look at authentication/session stuff and I'll be sorted :) All the others I've have found have been 0.1.x - not good!!!!

    Keep up the fantastic work and thanks again :)

    C

    PS - RE post 279, I disagree but I'm english ;-)

  289. 289 Rob...

    Chris,

    Thanks! I'm glad you've found it helpful.

    Regards,

    Rob...

  290. 290 Jorge

    Great Tutorial!!! thanks a lot..
    In the tutorial(1.4.0) you forget to load in index.php

    Zend_Loader::loadClass('Zend_Debug');
    Zend_Loader::loadClass('Zend_View');

    Put it in the next version...

    sorry but my english is very poor.
    regards

  291. 291 Rob...

    Hi Jorge,

    Thanks.

    I didn't realise that I had used Zend_Debug anywhere!

    Regards,

    Rob...

  292. 292 Bastien (french)

    Hello Rob!
    Great job!
    I'm using it for homework :p

    I'v got a problem when trying to go to "http://localhost/zf-tutorial/" : error 500 !
    but when going to "http://localhost/zf-tutorial/index" : normal index page of my website :(

    The other pages seem to be ok...

    Any idea ?

  293. 293 Bastien (french)

    If it helps, the errlog message is : "Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary."
    The owner of the server says that it doesn't like "RewriteRule .* index.php" >_

  294. 294 Bastien (french)

    to go far away in my investigation, I tried "http://localhost/zf-tutorial/index.php”

    So I think that if the rewrite rule had worked well, there would be no problem... it would have redirected me at index.php an so to the IndexControler/IndexAction page...

    help :'(

  295. 295 Bastien (french)

    A friend of mine helped me. I just had to modify jte rewrite rule .htaccess :

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php [L]

    php_flag magic_quotes_gpc off
    php_flag register_globals off

    It works now, but I absolutely don't understand why ...

  296. 296 Rob...

    Bastien,

    I'm glad you sorted it!

    Regards,

    Rob...

  297. 297 Bastien (french)

    I'm afraid I didn't, actually !!!
    I tried to create other controllers in the same directory that IndexController.php, but I can't call their actions... Same server error 500...

    Does somebody have an idea ?

  298. 298 Rob...

    What does your error log file say?

    Regards,

    Rob...

  299. 299 Bastien (french)

    My error log says :
    Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary.

  300. 300 Chris

    ->I accidently posted this under the Zend_Auth tutorial by accident. I will surely help out better here.
    Just posting to help out some would be users of the “Getting Started With Zend Framework - Tutorial”. On page 12 zf-tutorial/index.php will have to read: $db = Zend_Db::factory($config->db->adapter,
    $config->db->config->toArray()); instead of $db = Zend_Db::factory($config->db->adapter,
    $config->db->config->asArray()); in order to be used with ZF-RC2. Just a friendly reminder.

    Your tutorials are great. I would hate to see someone new to the framework give up because of something so small. Keep up the good work.

  301. 301 Bastien (french)

    I'm actually thinking about giving up... I have to finish my homework before tonight... just few hours to solve my problem and finish my homework.. I'm afraid I can't...

  302. 302 Allan Baasch

    Thanks for an excllent tutorial.

    I believe that:

    $this->view->baseUrl =
    $this->_request->getBaseUrl();

    in the init-method of the IndexController should be:

    $this->view->baseUrl =
    dirname($this->_request->getBaseUrl());

    Regards
    Allan

  303. 303 Allan Baasch

    Hi again.
    I'm sorry, my previous post was wrong - the "dirname()" part, not the "excellent tutorial part :)

    Regards
    Allan

  304. 304 RIchard

    There is a change with 1.0rc2, asArray() has been changed to toArray(). http://framework.zend.com/issues/browse/ZF-1461

    When you set the db factory with the config file, it has to be changed.

  305. 305 Daniel

    How can I get the ID of the recordset, which is saved? I need it for saving informations into another table.

    Regards,
    Daniel

  306. 306 Rob...

    Version 1.4.1 of the tutorial uses toArray. The SVN version of the code is correct, but I need to package up a zip file still.

    Regards,

    Rob...

  307. 307 Peter

    I use version 1.4.1

    After chapter 'Editing an Album' I get this notice in the input-fields:
    Trying to get property of non-object in /var/www/html/zend/site1/application/views/scripts/index/_form.phtml on line 5

    I compared my source code with the source code of 1.3 and I saw no differences.

    Regards,
    Peter

  308. 308 Peter

    Problem solved!

    I didn't put the id in the url:
    http://localhost/index/edit/id/1
    ----------------------------^

    (stupid!)

    Regards,
    Peter

  309. 309 San

    After upgrade to ZendFramework-1.0.0-RC1 Im getting following exception for edit album.

    exception 'Zend_Exception' with message 'No entry is registered for key 'post'' in C:\Program Files\Apache Group\Apache2\htdocs\test\zf-tutorial\library\Zend\Registry.php:145
    Stack trace:
    #0 C:\Program Files\Apache Group\Apache2\htdocs\test\zf-tutorial\library\Zend.php(298): Zend_Registry::get('post')
    #1 C:\Program Files\Apache Group\Apache2\htdocs\test\zf-tutorial\application\controllers\IndexController.php(103): Zend::registry('post')
    #2 C:\Program Files\Apache Group\Apache2\htdocs\test\zf-tutorial\library\Zend\Controller\Action.php(497): IndexController->editAction()
    #3 C:\Program Files\Apache Group\Apache2\htdocs\test\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php(230): Zend_Controller_Action->dispatch('editAction')
    #4 C:\Program Files\Apache Group\Apache2\htdocs\test\zf-tutorial\library\Zend\Controller\Front.php(889): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
    #5 C:\Program Files\Apache Group\Apache2\htdocs\test\zf-tutorial\index.php(84): Zend_Controller_Front->dispatch()
    #6 {main}

  310. 310 San

    I think error with the following statement..
    $post = Zend::registry('post');

    thanks
    San.

  311. 311 Rob...

    San,

    Have you read through the latest version of the Tutorial?

    Regards,

    Rob...

  312. 312 jude

    Hi Rob

    In order to do a fully query, I called upon the $db object. In the following code, $news in equivalent to your $album. Here is some Controller code:

    $news = new News();
    $db = $news->getAdapter();
    $sql = 'SELECT id, nid, title, author, intro FROM news ORDER BY id DESC';
    $result = $db->fetchAll($sql);

    How do I transition from this back to the news object/view:
    $this->view->news = $news->fetchAll();

  313. 313 Rob...

    Jude,

    With difficulty! If you use an SQL query, you have to create your own set of Zend_Db_Table_Rows.

    Alternatively, just use the array of results returned by fetchAll().

    Regards,

    Rob...

  314. 314 jude

    Hi Rob

    Thanks for replying.

    I could not do the default fetchAll() because it shows the oldest news item first !!!

    Anyway, I solved the problem by putting the following code in the Controller file:

    $news = new News();
    $db = $news->getAdapter();
    $sql = 'SELECT id, nid, seg, title, author, pub_date, intro FROM news ORDER BY id DESC';
    $this->view->news = $db->fetchAll($sql);

    I followed it up by view scripts like the following:
    escape($val['title']) ?>

    Works well.

    Thanks a lot

  315. 315 jude

    Sorry, the last line of code in the above should read:
    echo $this->escape($val['title'])

  316. 316 Rob...

    Jude,

    You should be able to do:

    <?php
    $news = new News();
    $this->view->news $news->fetchAll(null'id desc');
    
    

    Regards,

    Rob...

  317. 317 jude

    Hi Rob

    Thanks. Even though I have an alternative, its nice to know you can do DESC even with the default fetchAll(). It looks simpler and neater

  318. 318 Mattias

    Hello!

    I get this problem while checking the homepage through:
    http://localhost/zf-tutorial/
    on page 4 in the tutorial: getting-started-with-the-zend-framework_141

    Warning: include(./library/Zend/Loader.php) [function.include]: failed to open stream: Permission denied in /var/www/zf-tutorial/index.php on line 7

    Warning: include() [function.include]: Failed opening './library/Zend/Loader.php' for inclusion (include_path='.:./library:./application/models/:.:/usr/share/php:/usr/share/pear') in /var/www/zf-tutorial/index.php on line 7

    Fatal error: Class 'Zend_Loader' not found in /var/www/zf-tutorial/index.php on line 8

    Have i missed something?

    Best regards
    Mattias

  319. 319 Rob...

    Mattias,

    The information you require is in the error message. It failed to open to the file library/Zend/Loader.php. Either the file is missing or your webserver doesn't have permission to read it.

    Regards,

    Rob...

  320. 320 Vincent

    Wow. That was so cool - all of a sudden I could manage this CD catalogue. Really, really good tutorial. Thanks!

  321. 321 jude

    Hi Rob

    Since ZF RC3, 'index.php' appears on each URL for linked pages (except the default URL). Thus for a website called 'akra' and a Controller page called 'broadband', the default URL would be 'localhost/akra' and the broadband URL localhost/akra/index.php/index/broadband.

    In RC2, 'index.php' did not appear.

    I have tried conventional methods like adding some htaccess code to get rid of the index.php, but my efforts have been fruitless so far.

    Could you help?

  322. 322 Bryan

    I had similar problems with RC3. I switched to using the latest nightly snapshot and everything worked fine again.

  323. 323 jude

    thanks Bryan

  324. 324 Simon

    Excellent tutorial how would I go about including data in the different pages. For example on the Add page if I wanted to list the last 5 added cds in a block on the right (much like in a forum, latest posts...)? How do I get the data and add it to the view?
    Thanks

  325. 325 Rob...

    Simon,

    Thanks!

    I would use a view helper that accessed the model to collect the data required and displayed it as an unordered list. I'd then style with CSS.

    Regards,

    Rob...

  326. 326 Thiago Melo de Paula

    Rob,

    first of all, very nice tutorial! Thanks a lot!
    I'm reading version 1.4.1, using ZF 1.0 with PHP 5.2.3. After I've copied the IndexController.php file, I've tried to acess http://localhost/zf-tutorial/ but I got the following error: Zend_View_Exception: script 'index/index.phtml' not found in path (.\application\views\scripts\) in C:\wamp\www\zf-tutorial\library\Zend\View\Abstract.php on line 856.
    After research, I reach the following solution:
    add the following line to
    your bootstrap, prior to the call to dispatch():

    // Assuming $front is the front controller instance:
    $front->setParam('noViewRenderer', true);
    $front->dispatch();

    Best wishes,

    Thiago melo de Paula

  327. 327 Adam

    Rob,
    I am having a problem right from the beginning and can't seem to get past it. I have rewrite working correctly, but for some reason I get the following error on page 6, and it has be pretty baffled:

    Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'index/index.phtml' not found in path (./application/views/scripts/)' in /usr/share/php/library/Zend/View/Abstract.php:856 Stack trace: #0 /usr/share/php/library/Zend/View/Abstract.php(764): Zend_View_Abstract->_script('index/index.pht...') #1 /usr/share/php/library/Zend/Controller/Action/Helper/ViewRenderer.php(732): Zend_View_Abstract->render('index/index.pht...') #2 /usr/share/php/library/Zend/Controller/Action/Helper/ViewRenderer.php(753): Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/index.pht...', NULL) #3 /usr/share/php/library/Zend/Controller/Action/Helper/ViewRenderer.php(800): Zend_Controller_Action_Helper_ViewRenderer->render() #4 /usr/share/php/library/Zend/Controller/Action/HelperBroker.php(160): Zend_Controller_Action_Helper_ViewRenderer->postDispatch() #5 /usr/share/php/library/Zend/Controller/Action.php(504): Zend_Controller_Action_HelperBroker->notifyPostDispatch() #6 /usr/share/php/library/Zend/Controller/Dispatc in /usr/share/php/library/Zend/View/Abstract.php on line 856

    If I create the file '/zf-tutorial/application/scripts/index/index.phtml' the application completes as expected. Please help. What am I missing?

  328. 328 Adam

    I used the fix posted above by Thiago Melo de Paula, and it worked. Now I can continue with the tutorial.

  329. 329 Rob...

    Yep - page 6 doesn't make sense any more. I'll have to revise that section completely!

    Regards,

    Rob...

  330. 330 harry

    great job!
    1 a tips to share with someone got "mysql driver not installed"error;
    I found it very easy to set up in a shared Host, where I use bluehost,because they didn't install PDO, so later I figured out to change the /application/config.ini line1 into db.adatper=MYSQLI, and everything in this tutorials just works!

    2,I read all the tutorial against the Zend Framework API but still one little problem that I can't seem to understand :
    in an action function,what does this second arrow mean in " $this->view->baseUrl=$this->_request->getBaseUrl();"?

    because "baseUrl" is not an variable in view class nor is it a method in View, so here it just is a temporary name that can be used in the corresponding phtml file .the thing I can't understand is that when any object of view class is created all the fields and methods shoud be predefined .how can we add a runtime virable to an object? is this mechanism by PHP5 or by the Zend Framework?

    and still when I tried to delete all the "baseUrl" name in that phtml file,I supposed that there will be some error message in the controller like "undefined method or variable" but It doesn't.So I think the framework doesn't rap the view and phtml as an object.or this is just some mechanism to pass variable not strictly by OO concept?
    I can't find a clue in the API.

    I am new to php and did some java and ruby,so I must missed something here and hope you guys can give me some idea,,thanks!

  331. 331 jgreen

    Just a note, the zipped source files still contain these lines:

    // setup database
    $db = Zend_Db::factory($config->db->adapter, $config->db->config->asArray());

    which should be:

    // setup database
    $db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray());

  332. 332 jgreen

    re: harry

    $this->view->baseUrl
    creates the variable baseUrl for the view that belongs to the action you are in: This action's view's baseUrl.

    $this->_request->getBaseUrl()

    calls getBaseUrl in the _request object for this action.

    Hope that helps!

  333. 333 harry

    Thanks Jgreen, I thoough view means a view Object,seems not

  334. 334 Rob...

    Thiago & Adam,

    I've updated to 1.4.3 which fixes page 6 so that you don't get lots of scary errors!

    Regards,

    Rob...

  335. 335 mel

    Hi,
    when i downloaded the pdf file (for zend 1.0.0) and tried the tutorial out the error that i got was as follows:

    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.
    Error 500
    localhost
    07/18/07 10:03:10
    Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8d mod_autoindex_color PHP/5.2.1

    i want to know what is it am i doing wrong? And could some one please explain to me this statement.

    "...Note that the php_flag setting in .htaccess only works if you are using mod_php. If you use CGI/FastCGI, then you need to make sure that your php.ini is correct."

    Please do help,Thanks.

  336. 336 papaya

    Hi, i have a strange problem.
    I do use this settings in .htaccess
    RewriteEngine on
    RewriteRule .* index.php
    All things works if i write urlToSite/index or urlToSite/index.php, but if i only write urlToSite then i do get this error msg

    Not Found

    The requested URL /PathToPage/index.php was not found on this server.

    But the file is there with the right path. If i remove my .htaccess file and goes to urlToSite then i see index.php. Do you see anything wrong in my .htaccess

  337. 337 Kubek Bartosz

    @papaya: are You sure You are using the most recent ZF libs? Did You try the way, that is described in "Troubleshooting" sectinon in the tutorial?

  338. 338 Kubek Bartosz

    @Rob: thanks for linking me in :)

  339. 339 Alex Musayev

    Hello, Rob. Thank you for great article! I've made russian translation of your tutorial and published it here: http://archive.paradigm.ru/zend-fw-intro.pdf

    If you want, you can check it out and add this URL into you list.

  340. 340 Rob...

    Hi Axex!

    Thanks very much for your effort.

    Regards,

    Rob...

  341. 341 kang

    there is some errores!
    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (ex)' in C:\app_php5\zend_app\library\Zend\Controller\Dispatcher\Standard.php:194 Stack trace: #0 C:\app_php5\zend_app\library\Zend\Controller\Front.php(911): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:\app_php5\zend_app\index.php(28): Zend_Controller_Front->dispatch() #2 {main} thrown in C:\app_php5\zend_app\library\Zend\Controller\Dispatcher\Standard.php on line 194

    I have followed your tutorial.
    Thanks!

  342. 342 Agustin

    I cant run the example. Only have this message if i want to ckeck the URLs.

    Not Found
    The requested URL /zf-tutorial/index was not found on this server.
    Apache/2.0.54 (Win32) PHP/5.1.6 mod_auth_sspi/1.0.1 Server at PC1 Port 80

    I test it with:
    /zf-tutorial/index
    /zf-tutorial/index/index
    /zf-tutorial/index/add
    /zf-tutorial/index/edit
    /zf-tutorial/index/delete

    I dont find the error. Please i need some help

    my .htaccess is:
    RewriteEngine on
    RewriteRule .* index.php
    php_flag magic_quotes_gpc off
    php_flag register_globals off

    I use Apache 2.0.54, PHP 5.1.6.

  343. 343 terac

    I've a question regarding the common used view scripts. You set the data for these scripts in the init() method of controller (e.g. title or baseURL). But I have to to this in every controller, which want to use it.
    First idea is subclassing the action controller for common use of init method, but I find it not very elegant.
    Can you recomment a place?

    Great jop!
    Thanks, Falk.

  344. 344 phpdummi

    Hey Robby! :)
    Actually you're the only one, who provides a tutorial for zf 1.0.0 -great job!
    But I wouldn't leave a reply if I hadn't any trouble though ;)
    My Problem is: For don't hardcode the same HTML in every template, you added a "echo $this->render('header.phtml');" n the 'index.phtml' file. (Also one for the footer...)
    At this point, i get an error:
    "script 'header.phtml' not found in path (./application/views/scripts/)"
    I'm not very used to zf, all i did was following your instructions ...
    I've checked every line of my code, things seem to be okay.
    Any ideas?

    Btw: Thx for your help, this tutorial is just great :)

  345. 345 Nicolas

    Hi,
    Thanks for this tutorial.
    In my case the root is working but the other urls are not working :-(
    http://localhost/zf_tutorial/ :- WORKING

    http://localhost/zf_tutorial/index/add :- NOT WORKING

  346. 346 Rob...

    Agustin & Nicolas,

    Turn on the mod_rewrite extension in your Apache httpd.conf file. It's off by default in a standard Windows installation.

    Regards,

    Rob...

  347. 347 Rob...

    terac,

    Look at Two-Step views.

    Regards,

    Rob...

  348. 348 Rob...

    phpdummi,

    I'm more of a Rob, than a Robby!

    Have you put your header.phtml into the views/scripts directory? If so, I'd check the permissions on it.

    Regards,

    Rob...

  349. 349 Rob...

    kang,

    What url are you trying to access?

    Regards,

    Rob...

  350. 350 phpdummi

    Hi ... Rob!
    Sorry for making you trouble, but I've spend more than 1hour to get rid of this errormessage :x
    Now, after reading carefully what answered, I checked again ... and there it was! I was so dump to put the header- and footer.phtml into the views/scripts/index folder, instead of just views/scripts.
    Thx for your competent answer, commitable!
    Great tutorial, indeed.

  351. 351 Rob...

    phpdummi,

    Glad you sorted it :)

    Regards,

    Rob...

  352. 352 Mingan

    Hi,
    I like your tutorial but I have a problem. I followed tutorial step by step but nothing happened so I copied your code and still nothing. I try to access index.php (with code from the first step) and nothing happens. I mean I don't get any Fatal error! Can you help me please?

    Mingan

  353. 353 phpdummi

    It'd be better to solve the problem, if you explain WHAT happens!
    Do you get a white page, or what?
    Maybe your ModRewrite module isnt't working...

  354. 354 Mingan

    phpdummi: Nothing happens. I get clean white page.

  355. 355 Mingan

    phpdummi: I tried to make mistake or hide Zend folder. No change.

  356. 356 Rob...

    Mingan,

    Try turning on display_errors and setting error_reporting to E_ALL in your php.ini

    Regards,

    Rob...

  357. 357 Mingan

    Problem solved, PHP loaded different php.ini (with display_errors = off) file that I edited. Thank you very much

  358. 358 felipe tonello

    Hi roben,
    I would like to congrat you for this wonderfull article. And I would suggest an article with Zend Framework and Ajax applications.
    Keep with the good work.

    Cya,
    Felipe Tonello

  359. 359 kamal somani

    Great tutorial ... hats off..

  360. 360 Blaxx

    Hi Rob,

    First:
    Thanks for this great tutorial, keep up the good work!

    Second:
    I am having a little trouble with the following lines in Album.php:

  361. 361 Blaxx

    ok, seems your guestbook cut the last half of my post. Lets assume I copied the code for the Album.php from your latest pdf:

    I cant get the Album.php to work due to a parse error (expectin 'T_OLD_FUNCTION' or 'T_FUNCTION' or '}').

    I am using the latest MAMP version on a MAC OS X 10.4, means php 5 should be running properly.

    Any ideas?

    Many thanks,
    blaxx

  362. 362 Terry stalker

    Thanks for a super tutorial. I'm half way through. I'd just thought I'd mention that I got a bit hung-up when I got to the ADD action and saw:
    "// set up an "empty" album
    $this->view->album = new stdClass();"

    I was wondering where on earth the stdClass came from and what is was. After a search on Google I found out that "stdClass is a skeleton class, a blank canvas if you like". Could be worth adding a little explanation in the tutorial if your feeling extra nice ;o)

    Not only am I new to Zend Framework, but I'm quite new to OOP aspects of PHP.

  363. 363 Rob...

    There's a better way now as you can use nowadays.

    
    $albums = new Album();
    $this->view->album $albums->createRow();
    
    

    Regards,

    Rob...

  364. 364 NNemo

    Thanks for this tutorial!

  365. 365 Wizz

    Great tutorial, I just seem to be a bit st00pid...

    Now ZF has come out of beta, I'm willing to give it a serious try, but I already got stuck at the simple task of following this tut. Espescially the part with the view on page 7.

    Where do I have to create the Zend_View object? In the controller file, in the bootstrap file or somewhere else altogether?

    I keep getting an error/exception right now:

    ====================================
    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (product)' in C:\xampp\xampp\htdocs\tiesupply\library\Zend\Controller\Dispatcher\Standard.php:193
    Stack trace:
    #0 C:\xampp\xampp\htdocs\tiesupply\library\Zend\Controller\Front.php(911): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
    #1 C:\xampp\xampp\htdocs\tiesupply\index.php(21): Zend_Controller_Front->dispatch()
    #2 {main}
    thrown in C:\xampp\xampp\htdocs\tiesupply\library\Zend\Controller\Dispatcher\Standard.php on line 193
    ====================================

    I'm running Apache2.2.3 , PHP 5.2.0 and ZF 1.0... Although I still haven't included the view object, I doubt that this error has anything to do with that. Right?

    What am I doing wrong?

  366. 366 Wizz

    Little change in my message above (#365):
    ====================================
    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (index)' in C:\xampp\xampp\htdocs\zftest\library\Zend\Controller\Dispatcher\Standard.php:193
    Stack trace:
    #0 C:\xampp\xampp\htdocs\zftest\library\Zend\Controller\Front.php(911): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
    #1 C:\xampp\xampp\htdocs\zftest\index.php(21): Zend_Controller_Front->dispatch()
    #2 {main}
    thrown in C:\xampp\xampp\htdocs\zftest\library\Zend\Controller\Dispatcher\Standard.php on line 193
    ====================================

    I changed everything back to exactly follow the tutorial.

    Now if I go to: http://localhost/zftest/ or
    http://localhost/zftest/index/

    I get the exeption above...

    I did set the baseUrl to 'zftest', so that should solve that problem, right?

  367. 367 Wizz

    Never mind my message above (#365), I already found the problem...

    typo... doh!

    Greetz,

    Wizz

  368. 368 cshan

    I have a question about the zend_search_lucene part.
    When I create a index using:
    $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $content));

    In windowsXP, it works well and create one _0.cfs file which contains some information about the content.

    However, when I tried to migrate it to solaris10 os(Sunos sun4u sparc SUNW), it create a _0.cfs file but with nothing indexed in the file.

    Is it related to the os or the character set? I have tried many solutions, but still cannot get through this problem.

  369. 369 Tunnis

    @ comment 362/363

    Beeing the noob that i am:

    I'm not entirely sure how i would replace this:

    // set up an "empty" album
    $this->view->album = new stdClass(); $this->view->album->id = null; $this->view->album->artist = ''; $this->view->album->title ='';

    with this:

    $albums = new Album();
    $this->view->album = $albums->createRow();

    And what is the benefit?

  370. 370 Terry stalker

    Thanks for your reply.

    Just mentioning one other thing I got a bit 'hung up' on when reading through the tutorial. Although you tell us to turn magic_quotes_gpc Off I notice that the user provided data doesn't seem to have addslashes applied anywhere else in the script. After reading John Baldock's comment, above, I discover that the Zend framework does its own form of magic quoting. So, again, if you are feeling nice, it would be worth mentioning that in the tutorial. (I spent a long time searching the framework docs for any mentions of magic quoting to no avail - i think there should be section in the docs explaining when to quote and when not to quote).

  371. 371 Terry stalker

    Further to my last post re: "i think there should be section in the docs explaining when to quote and when not to quote"...

    I thought, if there isn't one already I may as well make one. So I'm building a Zend "when-to-quote Cheatsheet" here:
    http://www.eatmybusiness.com/food/2007/08/05/zend-framework-zend_db-when-to-quote-and-when-not-to-quote-user-input/34/

    Feel free to add to the list.

  372. 372 christian

    Hi :)

    So lets say that there's no albums in the database. When i do a fetchall and want to check if theres no data in it i do a simple

    if ($this->albums) :
    print some albums here
    else :
    print no albums added
    endif

    - but as i see it, it doesnt print the no albums thing. the reason must be that it exists, but it doesnt contain data, but still exists

    is there any workaround when using the fetchall?

  373. 373 Rob...

    Christian,

    How about

    
    if(count($this->albums) == 0) {
        // no albums
    } else {
        // one or more albums
    }
    
    

    Regards,

    Rob...

  374. 374 christian

    oh that was pretty straight forward :) why didnt i think of that!

    thanks! :) your a time saver!

  375. 375 Calvin Mitchell

    I get to the top of page 14 of 18 in the tutorial, just be fore the heading "Adding More Albums" and run the site expecting to see the two records. Instead I get the following:

    Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'footer.phtml' not found in path (./application/views/scripts/)' in /home/clmitch1/public_html/zf_tutorial/library/Zend/View/Abstract.php:856 Stack trace: #0 /home/clmitch1/public_html/zf_tutorial/library/Zend/View/Abstract.php(764): Zend_View_Abstract->_script('footer.phtml') #1 /home/clmitch1/public_html/zf_tutorial/application/views/scripts/index/index.phtml(20): Zend_View_Abstract->render('footer.phtml') #2 /home/clmitch1/public_html/zf_tutorial/library/Zend/View.php(46): include('/home/clmitch1/...') #3 /home/clmitch1/public_html/zf_tutorial/library/Zend/View/Abstract.php(768): Zend_View->_run('./application/v...') #4 /home/clmitch1/public_html/zf_tutorial/library/Zend/Controller/Action/Helper/ViewRenderer.php(742): Zend_View_Abstract->render('index/index.pht...') #5 /home/clmitch1/public_html/zf_tutorial/library/Zend/Controller/Action/Helper/ViewRenderer.php(763): Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/index.pht...', in /home/clmitch1/public_html/zf_tutorial/library/Zend/View/Abstract.php on line 856

  376. 376 Calvin Mitchell

    solved the problem: footer.phtml was mis-spelled as footer.html!!!

  377. 377 Balu

    "Notice how we check the $_SERVER['REQUEST_METHOD'] variable to see if the form has been submitted."

    No, I don't since you use $this->_request->isPost() ;-).

    Nice tutorial, just reading it though ATM. I hope to be able to follow it more closely soon.

  378. 378 Rob...

    Balu,

    Doh!

    Good catch!

    Regards,

    Rob...

  379. 379 gforce

    please do changes to $config->db->config->asArray())
    =>

    $config->db->config->toArray())

  380. 380 Rob...

    gforce,

    I thought that was corrected! Which version of the tutorial are you reading?

    Regards,

    Rob...

  381. 381 Trond

    Thanks for this tutorial. It suited me very well.

    very good for an entry to zend framework.

    Now to time to check out your Zend_Auth tutorial as well :)

    -trond

  382. 382 Rob...

    Thanks, Trond,

    I'm glad you found it useful.

    Regards,

    Rob...

  383. 383 Dave

    Like so many others have already said, "Thank you" for this tutorial. It has been very difficult to find one that works with 1.* version of the framework.

    That said, I've been able to find most of my typos and correct them w/o bothering you, but I can not find my problem on this one:

    I'm able to get everything to work except the actions for "add" and "edit". (Index list works fine and the display of add/edit works.)

    I'm using framework ver: 1.0.1 and tutorial version 1.4.4 on LAMP.

    When I click on the Add button to create a new record I get these messages:

    Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::add20methodAction() does not exist and was not trapped in __call()' in /var/www/html/zf-tutorial/library/Zend/Controller/Action.php:480 Stack trace: #0 [internal function]: Zend_Controller_Action->__call('add20methodActi...', Array) #1 /var/www/html/zf-tutorial/library/Zend/Controller/Action.php(497): IndexController->add20methodAction() #2 /var/www/html/zf-tutorial/library/Zend/Controller/Dispatcher/Standard.php(237): Zend_Controller_Action->dispatch('add20methodActi...') #3 /var/www/html/zf-tutorial/library/Zend/Controller/Front.php(911): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #4 /var/www/html/zf-tutorial/index.php(30): Zend_Controller_Front->dispatch() #5 {main} thrown in /var/www/html/zf-tutorial/library/Zend/Controller/Action.php on line 480

    My URL is: http://localhost/zf-tutorial/index/add%20method=?artist=dave&title=test&id=&add=Add

    I'm confused by the "%20" that is in the URL. I've looked for a Space (specifically in the action value), but can not find anything wrong. I've also tried to change the baseUrl value, but that doesn't seem to make any difference either.

    Any help would be appreciated. Thanks.

  384. 384 Rob...

    Dave,

    The %20 character is a space that's encoded.

    Regards,

    Rob...

  385. 385 Peterson

    I finally found a tutorial that follow my personal favorite rule for programming: KISS!

    Congratulations.

  386. 386 Dave

    Sorry, I should have said that I knew it is an encoded space. I'm not sure why it is there or if it is an indication of the problem.

    I feel confident that I've coded everything the way it is in the tutorial with the possible exception of a typo. I have 20+ years of I/T experience so I wouldn't consider myself a noob to programming. I am a noob to ZF.

    I have desk-checked my code several times, but I'm unable to determine the cause of the problem. Would anyone have a specific idea of what is causing the problem? I do have my "addAction()" function in zf-tutorial/controller/IndexController.php

    Thanks.

  387. 387 Dave

    Referencing #383 & 386, I found that I didn't have the closing quote on the form action.

    Rob, keep up the good work.

  388. 388 Rob...

    Dave,

    I'm glad you sorted it!

    Regards,

    Rob...

  389. 389 Rob...

    Peterson,

    I'm glad you found it useful.

    Rob...

  390. 390 binary

    I have found how to use Zend_Db_Select
    with rob tutorial..
    Hope you don't mind if I post it here rob.

    http://www.binarylabel.com/2007/08/19/usando-zend_db_select-para-querys-mas-complejos-o-con-join/

    if you want i can do it in english, just ask for it.

  391. 391 pyko

    hi Rob,
    thanks for the great tutorial!! I got it all working on localhost with WAMP, but when I uploaded the example to my webhost, i just get 404 not found error :(

    what could be the problem?
    thanks :)
    pyko

  392. 392 jeff

    I cannot get your code to work. The index.php loads ok with the list of albums. But none of the links (add, edit, delete) work for me.

    "The requested URL /zf_albums/index.php/index/edit/id/1 was not found on this server."

  393. 393 Rob...

    Pyko , Jeff,

    Either mod-rewrite isn't enabled or you haven't enabled use of .htaccess files.

    Regards,

    Rob...

  394. 394 Daniel

    Hi Rob,

    thanks for your tutorial and the time you are spending in supporting this ;-))

    Because I don't know, how to go forward, it would be nice to get yet another part of this tutorial.

    For example, if there is a table for artists (id, name) and in albums in the fild artist there is a reference to artists.id

    Regards,

    Daniel

  395. 395 Dix Mars

    Hi Rob,

    I don't quite understand part of the editAction function in IndexController.php.

    "if ($id !== false){...}else{...}"

    What does "!==" mean? Is it possible that ($id === flase) evaluates to true? Could you please give me an example scenario of the program executing the code within the braces after else?

    Thanks.

  396. 396 Steve Kamerman

    Dix Mars,

    This:
    if ($id !== false){…}else{…}

    Means:
    if $id is not EXACTLY equal in value and type (false, boolean) then this statement is false.

    Example:
    ( (0) !== false) (this is true)
    ( (0) != false) (this is false)
    ( '' !== false) (this is true)
    ( '' != false) (this is false)

  397. 397 sunan

    hi
    I already test your code in localhost
    The index.php load ok with the list of albums. But none of the links (add, edit, delete) work for me , message was Page Not Found
    http://localhost:8090/zf-tutorial/index/add

    already set mod_rewrite in httpd.conf uncommented LoadModule rewrite_module modules/mod_rewrite.so and test wiht phpinfo() mod_rewrite is ok can you tell me why ? and Zend Lib already in library ZF-tutorial ?

    but there was error in log apache
    [Tue Aug 28 14:16:41 2007] [error] [client 127.0.0.1] File does not exist: D:/Program Files/Apache Group/Apache2/htdocs/zf-tutorial/index

  398. 398 sunan

    hi
    I already test your code in localhost
    The index.php load ok with the list of albums. But none of the links (add, edit, delete) work for me , message was Page Not Found
    http://localhost:8090/zf-tutorial/index/add

    already set mod_rewrite in httpd.conf uncommented LoadModule rewrite_module modules/mod_rewrite.so and test wiht phpinfo() mod_rewrite is ok can you tell me why ? and Zend Lib already in library ZF-tutorial ?

    but there was error in log apache
    File does not exist: D:/Program Files/Apache Group/Apache2/htdocs/zf-tutorial/index

  399. 399 Dix Mars

    Thanks Steve! So (false !== false) is false, right?

  400. 400 Rushy2uk

    Is anyone else finding you cannot edit an album. It goes back to the homepage after pressing the edit button, but the changes are not saved to the database.

    Is there a way of displaying the last SQL query used by Zend_Db_Table?

  401. 401 Dix Mars

    Hi, Rushy2uk,

    If memory serves, you should change the name attribute of the hidden input in _form.phtml from 'ID' to 'id', as in the controller, it tries to getPost('id') rather than getPost('ID').

    It cost me a whole night to debug this. Anyway, is PHP case-sensitive?

  402. 402 Rob...

    Dix, Rushy2uk

    In this case, PHP is case-sensitive in terms of array elements.
    i.e.

    $array['ORANGE'] is not the same as $array['orange']

    Regards,

    Rob...

  403. 403 Chris

    Excellent tutorial.
    Really excellent.
    Makes it so simple to really get a solid grounding in the basic concepts.
    I read heaps of "getting started" type tutorials and none of them were even close to satisfying...
    Thanks. :-)

  404. 404 Peter

    This tutorial has been a great starting point for me!

    It would be wise however to add a note to this tutorial that in case of applying the _redirect method, output buffering should be ON (in php.ini or .htaccess) otherwise an exception error (headers already sent) will be raised!!

  405. 405 kojot

    My baseUrl is domain.com/tutorial. I've put tutorial code (with zf and changed config.ini) there.
    I've set BaseUrl with setBaseUrl in front controller setup to '/tutorial/'.

    And I've a problem.

    If I use link to add, edit or delete action - everything is OK. But when I'm then trying to use a button ('Add', 'Update' or 'Yes') - I've got a problem:
    - 'Add' and 'Update' makes correct changes to db, but there is no redirect then;
    - 'Delete' also makes changes (delete album) but there is 500 Internal Error then.

    So the problem is $this->_redirect('/'); or something other with redirection.

    When I've put options to redirect (array('code'=>303)) deleteAction redirect correctly to album list.
    But add and edit action still make no difference.

    Can you help me?

  406. 406 Rob...

    kojot,

    Look up the request object's baseUrl() function.

    Regards,

    Rob...

  407. 407 kojot

    Huh - nothing (i've looked over api doc).

    But I found that if I echo single space (echo ' ';) before usage of _redirect - everything is OK.
    But this isn't feasible solution.

  408. 408 adrian

    This has everything a great tutorial should be: simple enough to follow, complex enough to be useful, and logical enough to be understood. Thanks a million :-)

    One comment on the _form.phtml: since this form is used by both the Add and Edit pages, I would be inclined to use

    escape($this->action); ?>"

    instead of

  409. 409 adrian

    nice filtering :-)
    one more time ... use

    type="submit" name="?php echo $this->escape($this->action); ?"

    instead of

    type="submit" name="add"

  410. 410 Rob...

    Adrian,

    Maybe. As we don't test for the submit button in the code, what benefit would it bring?

    Regards,

    Rob...

  411. 411 seonet™

    Thanks for this tutorials, it may help me much more.
    ^^

  412. 412 elis

    Hi!, I'm doing the tutorial an I have a problem on Album List, I recibe this message:

    Notice: Trying to get property of non-object in C:\xampp\htdocs\zf-tutorial\index.php on line 22

    Notice: Trying to get property of non-object in C:\xampp\htdocs\zf-tutorial\index.php on line 22

    Fatal error: Call to a member function toArray() on a non-object in C:\xampp\htdocs\zf-tutorial\index.php on line 22

    Can tell me where can be happening??!
    Thanks a lot, elis

  413. 413 elis

    Forgett my before mail!!! I can solve it!!!

    Your tutorial is fantastic! Thanks very much !!!

  414. 414 hiutopor

    Hello

    Very interesting information! Thanks!

    Bye

  415. 415 elis

    I receive this error and i don't know how to solve it because the table album has a primary key: (i`m usign PDO_Sqlite adapter, there is another way to connect to mysql widthout an adapter?!)

    Fatal error: Uncaught exception 'Zend_Db_Table_Exception' with message 'Primary key column(s) (id) are not columns in this table ()' in /var/www/html/zf-tutorial/library/Zend/Db/Table/Abstract.php:651 Stack trace: #0 /var/www/html/zf-tutorial/library/Zend/Db/Table/Abstract.php(529): Zend_Db_Table_Abstract->_setupPrimaryKey() #1 /var/www/html/zf-tutorial/library/Zend/Db/Table/Abstract.php(264): Zend_Db_Table_Abstract->_setup() #2 /var/www/html/zf-tutorial/application/controllers/IndexController.php(15): Zend_Db_Table_Abstract->__construct() #3 /var/www/html/zf-tutorial/library/Zend/Controller/Action.php(497): IndexController->indexAction() #4 /var/www/html/zf-tutorial/library/Zend/Controller/Dispatcher/Standard.php(237): Zend_Controller_Action->dispatch('indexAction') #5 /var/www/html/zf-tutorial/library/Zend/Controller/Front.php(911): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #6 /var/www/html/zf-tutorial/index.php(42): Zend_Controller_Front-> in /var/www/html/zf-tutorial/library/Zend/Db/Table/Abstract.php on line 651

    Thanks very much, elisa

  416. 416 Vijai

    Hello,

    First of all Thanks A Lot for the tutorial, A great way know about ZF.

    I am a newbie in Zend Framework and used your ex. code for studies. But now I am STUCK. Everthing is fine except PDO... I have WAMP with PHP 5.2.3 and MySQL 5.0.41 installed in my XP machine. Also my PDO are set ON.

    extension=php_pdo.dll
    extension=php_pdo_sqlite.dll
    extension=php_pdo_mysql.dll

    But when I am running the index.php from "http://localhost/~test/" its showing error message:

    Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The mysql driver is not currently installed' in C:\wamp\www\test\library\Zend\Db\Adapter\Pdo\Abstract.php:104 Stack trace: #0 C:\wamp\www\test\library\Zend\Db\Adapter\Abstract.php(263): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 C:\wamp\www\test\library\Zend\Db\Adapter\Pdo\Abstract.php(206): Zend_Db_Adapter_Abstract->query('DESCRIBE `album...', Array) #2 C:\wamp\www\test\library\Zend\Db\Adapter\Pdo\Mysql.php(138): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE `album...') #3 C:\wamp\www\test\library\Zend\Db\Table\Abstract.php(595): Zend_Db_Adapter_Pdo_Mysql->describeTable('album', NULL) #4 C:\wamp\www\test\library\Zend\Db\Table\Abstract.php(528): Zend_Db_Table_Abstract->_setupMetadata() #5 C:\wamp\www\test\library\Zend\Db\Table\Abstract.php(264): Zend_Db_Table_Abstract->_setup() #6 C:\wamp\www\test\application\controllers\IndexController.php(32): Zend_Db_Table_Abstract->__construct() #7 C:\wamp\www\test\library\Zend\Controller\Action.php(497): Index in C:\wamp\www\test\library\Zend\Db\Adapter\Pdo\Abstract.php on line 104

    WHAT DID I DO WRONG? I am sitting in front of it for 3 days and there is no imporvemnet :(. Please help me. Thanks a lot in advance!!!

  417. 417 Vijai

    Hello,

    Dont bother about my message... I got it fixed at last... The problem was with multiple config files (php.ini), as Rob as explained earlier "Multiple php.ini files in a system can cause a world of pain"... I am releaved :)

  418. 418 Marc

    Hello!

    Since this is a place where everybody is discussing, I want to know if someone can fix my problem!

    I'm actually having some problems using PDO_PGSQL and schemas. Following the tutorial present on this site, I've made the necessary modifications to run the zf-tutorial on Postgre, and that worked. After that, I brought to my work the idea of using ZendFramework, and everybody LIKED it!

    The problem started when I needed to configure a schema (let's say for now, the "foo" schema). On the model constructor I needed to pass one more string on the array wich was the schema name string. But it doesn't find any of the relations!

    I always get an error message telling me that no relation was found. But if I put my tables on the public schema, everything works fine! I've already tried hundreds of configurations, and readed the whole code of Zend_Db, but didn't figured the problem out.

    Am I missing something? Can someone help me? Is this a bug with PDO?

    Sorry for my bad english, I'm brazilian :)

    Marc Abillama

  419. 419 Jeremy

    For Mac Users: So I spent about 3 days trying to figure out why I was getting an Internal Server 500 error, and I've finally figured it out. I noticed some other people had the same problem, so I figured I'd share with you guys...

    I've been editing the .htaccess file (with the Rewrite rules) in TextEdit. Turns out, TextEdit adds Mac line breaks, causing the server to get confused. Instead, I downloaded TextWrangler (from the guys at BareBones), made sure I saved the .htaccess file with Unix line breaks, and voila! The Zend Framework works like a charm. Also - TextWrangler allows you to open "Hidden" files, so you don't have to use some crazy tool (like TinkerTool) to display hidden files on your Mac.

    I'm relatively new to Mac's, so I'm used to Windows Notepad, which edited .htaccess files easily.

    Now I can sleep better...

  420. 420 Rob...

    Thanks for the heads-up Jeremy!

    Regards,

    Rob...

  421. 421 r0sko

    nice tutorial but that would be greater if you show how to connect different tables (posts with comments, albums and categories, etc). i still don't get it.

    any other framework presentation tutorials(cakephp, ror, symfony) shows how to create blog. this is very usefull and show the way to create almost anything (like forum, news, tags, etc).

    please add this thing to tutorial or just explain this important feature in comments. thank you.

  422. 422 Daniel Skinner

    Absolutely fantastic tutorial! Exactly what I needed to get me started with the Zend Framework.

    I think that the tutorial should stick to the Zend Coding style guidlines just to be complete. I know it's picky but strings should be single quoted!

    Thanks for this!

  423. 423 milunes

    Hey guys why is it 'echo $this->_request->getBaseUrl();'
    doesn't seem to output anything :s ?

    ps:, Thank you for this great tutorial, it really help me a lot on startin ZF.

  424. 424 milunes

    hmm.. never mind it seem that '$this->_request->getBaseUrl()' wont produce anything if I use vhost.

    when I'm not using vhost then my URL will be : http://localhost/demo_app/public/item/add
    then $this->_request->getBaseUrl() would produce /demo_app/public :p

    >.

  425. 425 Rob...

    Daniel,

    Thanks :)

    (Can you tell that I come from a C background?!)

    Regards,

    Rob...

  426. 426 Rob...

    milunes,

    As you have seen, if your project is at the top of a vhost, then the base url is blank.

    Regards,

    Rob...

  427. 427 Nils Dehl

    Very Nice Work!

    It help very much to start with ZF 1.0.0

    Thank You

  428. 428 Dennis Fogg

    I used the code in your great tutorial to do a simple performance study on the Zend Framework. The results (with code thanks to you!) is at http://www.nabble.com/Re%3A-ZF-performance-advice-p13185506s16154.html

    Dennis

  429. 429 huangam

    Zend Framework has unveiled the version 1.0.2, I hope your tutorial code can also upgraded.

    huangam

  430. 430 Rob...

    Huangam,

    It should work fine with 1.0.2.

    Regards,

    Rob...

  431. 431 miggs

    Brilliant,

    Thank you so much, the tutorial was a great way to get started with ZF.

  432. 432 mindphp

    Thank for example

  433. 433 alikabok

    Good Job here. It helped me get started with ZF. Thanks!

  434. 434 Dinesh

    Hi, nice tutorial.
    But I am having the following error can you help.

    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (zf-tutorial)' in /var/www/html/zf-tutorial/library/Zend/Controller/Dispatcher/Standard.php:193 Stack trace: #0 /var/www/html/zf-tutorial/library/Zend/Controller/Front.php(911): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /var/www/html/zf-tutorial/index.php(33): Zend_Controller_Front->dispatch() #2 {main} thrown in /var/www/html/zf-tutorial/library/Zend/Controller/Dispatcher/Standard.php on line 193

  435. 435 Rob...

    Dinesh,

    If I was to guess, I'd say that you have a problem with htaccess rules.

    Regards,

    Rob...

  436. 436 EllisGL

    I'm getting the following errors:
    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_Broker' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 152

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 163

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 166

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\index.php on line 10

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 774

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 306

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 583

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 585

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 246

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 274

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\ErrorHandler.php on line 117

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 60

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 72

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_Broker' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 83

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Action_Helper_ViewRenderer' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Action\HelperBroker.php on line 70

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Action_Helper_ViewRenderer' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Action\HelperBroker.php on line 73

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Http.php on line 351

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 829

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 437

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 447

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 449

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 849

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 600

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 610

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 612

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 174

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 176

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 178

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 53

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 55

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 56

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_Broker' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 182

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 201

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 203

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 205

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 75

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 77

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 78

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_Broker' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 210

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Router_Rewrite' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Abstract.php on line 95

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Router_Rewrite' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 475

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Router_Rewrite' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 485

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 487

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Router_Rewrite' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 504

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Router_Rewrite' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 863

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Router_Rewrite' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Abstract.php on line 95

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 585

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 869

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 306

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 367

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 369

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 370

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 231

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 233

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 98

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Rewrite.php on line 233

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 166

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Abstract.php on line 164

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Abstract.php on line 165

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 306

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 583

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 585

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Rewrite.php on line 70

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Abstract.php on line 159

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Route\Module.php on line 92

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Route\Module.php on line 102

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Router_Route_Module' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Rewrite.php on line 74

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Http.php on line 432

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Http.php on line 544

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Router_Route_Module' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Rewrite.php on line 247

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Rewrite.php on line 259

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 283

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Http.php on line 578

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 126

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 283

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Http.php on line 578

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 152

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 283

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Http.php on line 578

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 100

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Router\Rewrite.php on line 255

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 254

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 256

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 109

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 281

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 283

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 118

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 326

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 303

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Plugin_ErrorHandler' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Broker.php on line 305

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Plugin\Abstract.php on line 132

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php on line 183

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php on line 183

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 367

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Response_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 369

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Dispatcher_Standard' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 370

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php on line 158

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php on line 308

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php on line 360

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 126

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 152

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php on line 166

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 265

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 268

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Front' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Abstract.php on line 268

    Strict Standards: Implicit cloning object of class 'Zend_Controller_Request_Http' because of 'zend.ze1_compatibility_mode' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Request\Abstract.php on line 100

    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Cannot load controller class "IndexController" from file "IndexController.php" in directory "\"' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php:284 Stack trace: #0 C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php(208): Zend_Controller_Dispatcher_Standard->loadClass('IndexController') #1 C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php(920): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #2 C:\wamp\www\zf-tutorial\index.php(15): Zend_Controller_Front->dispatch() #3 {main} thrown in C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php on line 284

  437. 437 EllisGL

    Never mind.. Found the part saying there should be a fatal error.

  438. 438 Rob...

    Hi EllisGL,

    I would set the zend.ze1_compatibility_mode setting in your php.ini too!

    Rob...

  439. 439 bulupe

    Hi Rob,
    This is really the best tutorial (v.1.4.5) i have seen about ZF. Thank you. I have added setCredentialTreatment to login action to use mysql password functionality.

    I m just curious that what you think about complex views (pages) in ZF, as i read there are some serious discussions going out there.

    I m really stuck with the idea of implementing a complex page which includes, ajax, flash, html.

    I ll be really thankful if you can write about complex views, at least please provide useful links u have.

    Thank you again for this tutorial.
    Bulent.

  440. 440 Dinesh

    Hi Rob,

    Thanks for the pointer.

    I will check the htaccess rules.

    Best regards,
    Dinesh.

  441. 441 Agustin

    Hello there...

    Well, lot of problems with the PDO installation on my hosting server. So, I can't use PDO_MYSQL in the config.ini.

    Then two days of google "Zend without PDO", and (this look good, but... checkout your self), for me don't function at all.

    http://devzone.zend.com/node/view/id/1553

    So, finally, third day of deseperation, I change the controller in the confing.ini to MYSQLI and I GOT IT!!!!... YES.. FUNCTION.

  442. 442 Rob...

    Hi Agustin,

    Excellent! I've just started playing with the MYSQLI adapter myself.

    Regards,

    Rob...

  443. 443 Alikabok

    Hi Rob,

    I was wondering how can I use the "join" command in this example. I've been trying it myself but to no avail:

    Zend_Loader::loadClass('Booksdata');
    Zend_Loader::loadClass('Author');

    $booknum = (int)$this->_request->getParam('booknum', 0);
    $booksdata = new Booksdata();
    $booksdata->fetchRow('booknum='.$booknum);
    $booksdata->getAdapter();
    $sql = $db->select();
    $sql->from('booksdata', '*');
    $sql->where('booksdata.booknum =?', $booknum);
    $this->view->booksdata=$db->fetchall($sql);

    I wanted to left join the table "author" into table "booksdata".
    Your help would greatly be appreciated.

    Many thanks from the Philippines!

  444. 444 Rob...

    Hi Alikabok,

    You need to wait until Simon Mundy's Zend_Db_Table enhancements are in before you can do joins with Zend_Db_Tables. Zend_Db_Select supports joins though as you can see in the manual at http://framework.zend.com/manual/en/zend.db.select.html#zend.db.select.building.join.example-no-columns

    Regards,

    Rob...

  445. 445 jay

    Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::deleteAction() does not exist and was not trapped in __call()' in D:\xampp\htdocs\zf-tutorial\library\Zend\Controller\Action.php:480 Stack trace: #0 [internal function]: Zend_Controller_Action->__call('deleteAction', Array) #1 D:\xampp\htdocs\zf-tutorial\library\Zend\Controller\Action.php(497): IndexController->deleteAction() #2 D:\xampp\htdocs\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php(238): Zend_Controller_Action->dispatch('deleteAction') #3 D:\xampp\htdocs\zf-tutorial\library\Zend\Controller\Front.php(920): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #4 D:\xampp\htdocs\zf-tutorial\index.php(31): Zend_Controller_Front->dispatch() #5 {main} thrown in D:\xampp\htdocs\zf-tutorial\library\Zend\Controller\Action.php on line 480

    all actions are working except delete
    can any one help pls

  446. 446 Rob...

    Hi Jay,

    Double check the spelling of the deleteAction() function which should be in the IndexController class.

    Regards

    Rob...

  447. 447 Greg

    Rob,

    Great tutorial. I sent you an email before finding this page.

    Thanks,

  448. 448 Jon

    I am receiving an identical message to jay (post #445), I checked the spelling and it is correct.

    (Delete if the only element not working.)

    Thank you for your help. Thank you for taking the time to write this excellent tutorial.

  449. 449 Jon

    Well, after much tinkering with the code...for some reason, adding another closing curly brace at the end of the deleteAction() function corrected everything. However, that curly brace does not seem to be connected to anything...so I am going to double-check all the segments of code. Problem solved though.

  450. 450 Peter

    It's a very great intro tutorial. If you extend it with some functionality required modular structure and authentication you will be the best ;-)

  451. 451 Maslintcho

    Great tutorial, thank you very much!

  452. 452 Dennis

    Great tutorial!
    Thank you very much, slowly i understand how to use this damned framework ;)

  453. 453 Rob...

    I'm glad the tutorial is still helpful to you guys!

    Regards,

    Rob...

  454. 454 Bart van Berkel

    Hi Rob,

    Thanks a lot for this tutorial.
    The reading and understanding how the zend framework works is very easy that you written it.

    Only now i am trying to make my own application, and the basics works fine. But i need some little modification with the fetchRow() methode.

    In youre tutorial you explained that you can echo data with fetchAll() that i understand. But i need to have 1 row back. For the record i will explaine what i mean, my english is not at the best so i hope you understand ;0)

    In just plain php it would like this:

    $sql = "SELECT title,
    artist
    FROM album
    WHERE id = 1";

    and then too echo:
    $result = mysql_fetch_assoc($sql);

    echo $result['title'];
    echo $result['artist'];

    But how doe this work in the zend framework? can you explain that at some time or make a little tutorial from it?

    thanks a lot!

    regards,

    Bart

  455. 455 Rob...

    Bart,

    You need:

    
    $row $table->fetchRow('id='.(int)$id);
    
    

    Doesn't give you an assoc type output; you need Zend_Db for that.

    Regards,

    Rob...

  456. 456 naisioxerloro

    Hi.
    Good design, who make it?

  457. 457 Rob...

    naisioxerloro,

    I did :) Which is one reason why it is simple...

    Regards,

    Rob...

  458. 458 Nilesh Gurav

    Hi Rob,

    I have seen the error which i mentioned below i above question answer session.

    Warning: Zend_View::include(./application/views\) [function.Zend-View-include]: failed to open stream: Permission denied in C:\xampp\htdocs\zf-tutorial\library\Zend\View.php on line 46

    Warning: Zend_View::include() [function.include]: Failed opening './application/views\' for inclusion (include_path='.;./library/;./application/models') in C:\xampp\htdocs\zf-tutorial\library\Zend\View.php on line 46

    But still have not solve the problem using the solution u metioned above.

    Please help me in this.

    Thanks & Regards,
    Nilesh Gurav

  459. 459 Jon

    How do you add a simple and not have it redirected to the same site?

  460. 460 Jon

    Sorry....how do you add a simple..
    a href=www.example.com without it being redirected to the index.

  461. 461 Nour

    Hallo Rob,
    I have a class, i want that this class each time be executed. where can i call it.
    this is definition of class:
    class IndexController extends Zend_Controller_Action
    {
    code...
    }

    Thank you.

  462. 462 Rob...

    Nour,

    What do you mean? You could put your code into the init() function for a given controller or you could create a new controller class that all your actual controllers extend and put the code in the init() function of that class.

    Regards,

    Rob...

  463. 463 Nour

    but i get this error :(Strict Standards: Creating default object from empty value in C:/...) when i do this :
    class IndexController extends Zend_Controller_Action
    {
    function init()
    {
    Zend_Loader::loadClass('pages');
    $this->view->baseUrl = $this->_request->getBaseUrl();
    Zend_Loader::loadClass('CategoryController');
    $CategoryController = new CategoryController();
    $CategoryController->indexAction();

    }

    //get homepage content from pages Table
    function indexAction()
    {
    ...
    }

    }

  464. 464 Frank

    Hi, great tutorial!

    I've just downloaded the latest pdf and the latest zip. The app. work and is all good exept that the stylesheet is not showing. I replaced the lib with the latest release (1.0.3) and the app still is working goog, but no stlesheet???????

    Firebug is giving me this error: MIME type is text/html not text/css

    Where can I fix this????

  465. 465 Mathew

    Hi,

    Excellent tutorial. I've been looking into the Zend Framework for a while now because of it's vast feature set.

    This tutorial is great at explaining the basics which a lot of other tutorials miss out.

    Many thanks
    -Mathew

  466. 466 Rob...

    Frank,

    Sorry - I have no idea :(

    Regards,

    Rob...

  467. 467 Rob...

    Hi Matthew!

    I'm glad you found it useful.

    Regards,

    Rob...

  468. 468 Mathew

    A tip for the tutorial to make those template files a little bit easier to read is instead of echo'ing everything you can use the following syntax to do the same thing.

    By the way, it's Mathew, one 't'. ;)

  469. 469 Mathew

    It seems you don't allow PHP code in the comments. I'll send you an email.

  470. 470 Rob...

    Sorry Mathew!

    I don't see why you aren't allowed to do PHP code though...

    Regards,

    Rob...

  471. 471 Mathew

    The first code block is what I was trying to do.

    http://hudzilla.org/phpwiki/index.php?title=Opening_and_closing_code_islands

  472. 472 Ingus

    Latvian translation of 1.4.5 available at:
    http://webtech.lv/rakstu-darbi/zend-framework/

  473. 473 Zied

    Congratulations, the tutorial is very simple and helpful.
    But I still have one problem. I've downloaded the full Zip file of tutorial including ZF1.0.1. The first page is displayed. But, when I try to click on the link 'Add a New Album' or 'Delete' or 'modify Album', IE shows an error page with message 'PAGE NOT FOUND'.
    Could you help me please to undertand the source of the problem and to resolve it.
    Thanks

  474. 474 Rob...

    Zied,

    Your rewrite rules in .htaccess are not working. I suspect that you need to put in AllowOverride All in your httpd.conf file somewhere.

    Regards,

    Rob...

  475. 475 elis

    I receive this error and i don't know how to solve it because the table album has a primary key: (i'm usign PDO_Sqlite adapter, there is another way to connect to mysql widthout an adapter?!)

    Fatal error: Uncaught exception 'Zend_Db_Table_Exception' with message 'Primary key column(s) (id) are not columns in this table ()' in /var/www/html/zf-tutorial/library/Zend/Db/Table/Abstract.php:651 Stack trace: #0 /var/www/html/zf-tutorial/library/Zend/Db/Table/Abstract.php(529): Zend_Db_Table_Abstract->_setupPrimaryKey() #1 /var/www/html/zf-tutorial/library/Zend/Db/Table/Abstract.php(264): Zend_Db_Table_Abstract->_setup() #2 /var/www/html/zf-tutorial/application/controllers/IndexController.php(15): Zend_Db_Table_Abstract->__construct() #3 /var/www/html/zf-tutorial/library/Zend/Controller/Action.php(497): IndexController->indexAction() #4 /var/www/html/zf-tutorial/library/Zend/Controller/Dispatcher/Standard.php(237): Zend_Controller_Action->dispatch('indexAction') #5 /var/www/html/zf-tutorial/library/Zend/Controller/Front.php(911): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #6 /var/www/html/zf-tutorial/index.php(42): Zend_Controller_Front-> in /var/www/html/zf-tutorial/library/Zend/Db/Table/Abstract.php on line 651

    Thanks very much, elisa

  476. 476 Niko

    After beginning first with the ZF-Standard-manual on "Framework MVC" I didn't get the starting-point !
    Then I found your tutorial, it's a real bootstrapped-Tutorial ! After solving the problem to connect to my PGSQL (had php_pgsql.dll instead of php_pdo_pgsql.dll and php_pdo.dll) everything worked fine. Your code really worked by copy and paste from your sheet ! Thanks a lot.
    Niko

  477. 477 Rob...

    Hi Niko,

    I'm glad you found it useful. The idea of the tutorial is that it gets you going and then you have a base from which to experiment.

    In my experience, it's much easier to play when you have something working!

    Regards,

    Rob...

  478. 478 Bevan

    Hi Excellent Tut...

    I have one question, I also notice that i cant get my stylesheet or my js code to load the application is sitting in a subfolder called /zendtut
    but when i goto /zendtut/public/styles/site.css as a test i get a
    exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (public)'

    anyone have any ideas?

  479. 479 Rob...

    Hi Bevan,

    At a guess, the .htaccess file is missing in the public subdirectory.

    Regards,

    Rob...

  480. 480 elis

    Hi! I can solve the problem and i have the tutorial working! thanks for the great tutorial!!!... I want to put in the form to select elements related like Country and State... Can u give me a clue of where i should put the code to access Country and State tables?...

    Thans elisss

  481. 481 Rob...

    elis,

    I'm not sure what you mean. I would use the formSelect() view helper personally.

    Regards,

    Rob...

  482. 482 Callan

    Hi Rob,

    Firstly - your tutorial is great. Can't wait for the book.

    Secondly, I tried your tutorial with the latest version of ZF 1.0.3, everything worked except when 'Adding an album' at which point I got the following:

    Fatal error: Uncaught exception 'Zend_Db_Table_Row_Exception' with message 'Specified column "id" is not in the row' ..along with a stack trace.

    I couldn't find the bug so i downloaded your completed tutorial which is bundled with ZF (1.0.1) and It worked fine. However, if I replace the Zend directory bundled with your tutorial with the latest version (i.e. 1.0.3) then the error returns.

    Any ideas?
    Thanks,
    Callan

  483. 483 Chuck

    I was having issues with the .htaccess file from displaying error 500 and css files not being read despite the correct path under xampp for windows. I solved my problems by adding the opening tag and the closing tag. This is how my .htaccess file looks like.

    RewriteEngine on
    RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

    php_flag magic_quotes_gpc off
    php_flag register_globals off

    Hope this helps!

  484. 484 Chuck

    ""

    RewriteEngine on
    RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

    php_flag magic_quotes_gpc off
    php_flag register_globals off

    ""

    remove the quotes.

  485. 485 webz

    Hi rob,

    Sorry for being such a noob but i was about to start learning PHP Framework and i found your tutorials very helpful to me.

    Now i try to add a different function or module on the album sample you made like i add news, but i get confusing in the controller area as well as in handling it on VIEW, what i did is i just make the same on the Model Part as what you did but on the Controller can you help me on how to work for it, to work those two functions, i hope that you can help me. Thanks a lot :)

  486. 486 gadi eichhorn

    Great tutorial!

    thanks very much. really got me started quickly and with the correct set-up.

    It is the only set-up that worked for me on my win 2000 server with XAMPP.

    I had to change the Apache mod_rewrite as it is not enabled with XAMPP by default.

    Thanks a lot!
    G.

  487. 487 Nour

    Halo Rob,
    I have a question. I want to redirect the user to index page if hi fill a wrong controller or action of that controller.
    For example: the url is : http://www.zfforum.nl/news

    and the user fill:
    http://www.zfforum.nl/newsss
    then i want redirect to:
    http://www.zfforum.nl/index.

    Can i still use this action:noRouteAction()

  488. 488 Rob...

    Hi Nour,

    You can, but you are better off using the ErrorController plugin

    Look at section 10.5.2 of
    http://framework.zend.com/manual/en/zend.controller.plugins.html#zend.controller.plugins.standard

    Regards,

    Rob...

  489. 489 Nour

    Hai Rob,
    I have 2 modules: default and admin

    I use errorHandler for my application. if there is no controller or action the method errorAction of the errorController redirect to frontEnd default/index and I want to check of the current module is admin if it is then i want to redirect to admin/index

    my queston how can i get the current module.
    --------------
    can i use this:
    $this->view->module = $this->getRequest();

  490. 490 Nour

    Tanks Rob ihave found it:
    $this->getRequest()->getModuleName()

  491. 491 Liz

    Rob,

    Thanks for the amazingly helpful tutorial! I used it as a jumping-off point for a generic skeleton project using Zend Framework (1.5 preview) and Smarty.

    It's at http://lizwarner.com/projects.html and I'm hoping it might be useful to people who end up on this page.

  492. 492 Keith

    Thx for the tutorial. First, I'm somewhat new to ZF, so my apologies for asking what might be obvious to others The ZF Reference shows the following set-up in the Quick Start section of the manaul:

    application/
    controllers/
    IndexController.php
    models/
    views/
    scripts/
    index/
    index.phtml
    helpers/
    filters/
    html/
    .htaccess
    index.php

    with html being the document root. You have a somewhat different set up. The application directory is inside the document root (see below), for example.

    zf-tutorial/
    /application
    /controllers
    /models
    /views
    /filters
    /helpers
    /scripts
    /library
    /public
    /images
    /scripts
    /styles

    Any comments on the pros and cons of each approach would be appreciated.

    Thx, Keith

  493. 493 Rob...

    Hi Keith,

    My directory structure is geared around a shared hosting scenario where you don't have access to any other directory other than the webroot. This was to maximise the breadth of people who could benefit from it.

    Personally, I run all my sites closer to the ZF recommended structure.

    Regards,

    Rob...

  494. 494 Keith

    Thx for the quick reply. That makes perfect sense and helps me quite a bit.

    thx again, Keith

  495. 495 Joe

    The guide was quite good, but I have a small problem with my test site that I created. The CSS does not seem to work and I cannot get images to display. I am using the Zend Framework 1.0.5 and using XAMPP for my desktop server. Beside those problems, I have had no problems.

    Thank you,

    Joe

  496. 496 Rob...

    Joe,

    What do you get if you navigate directly to a CSS file?

    Rob...

  497. 497 rsg

    Hi Rob,

    I have the "same" problem like 416 Vijai.

    Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The mysql driver is not currently installed' in C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Adapter\Pdo\Abstract.php:104 Stack trace: #0 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Adapter\Abstract.php(263): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Adapter\Pdo\Abstract.php(206): Zend_Db_Adapter_Abstract->query('DESCRIBE `album...', Array) #2 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Adapter\Pdo\Mysql.php(138): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE `album...') #3 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Table\Abstract.php(595): Zend_Db_Adapter_Pdo_Mysql->describeTable('album', NULL) #4 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Table\Abstract.php(528): Zend_Db_Table_Abstract->_setupMetadata() #5 C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Table\A in C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\library\Zend\Db\Adapter\Pdo\Abstract.php on line 104

    I have 4 php.ini files
    In this is whole configuration:
    C:\Program Files\Zend\Core for Oracle\etc\php.ini

    in this:
    C:\Program Files\Zend\Core for Oracle\setup\zui_files\php.ini

    extension_dir = "C:\Program Files\Zend\Core for Oracle\setup\zui_files"
    extension = cuwin.dll
    extension = php_ng.dll
    zend_extension = "C:\Program Files\Zend\Core for Oracle\lib\zend\optimizer\php-5.2.x\ZendOptimizer.dll"

    in this:
    c:\ Program Files\Zend\ZendStudio_for_i5OS-5.5.0\bin\php\php5.ini

    I have:
    extension_dir=C:\Program Files\Zend\ZendStudio_for_i5OS-5.5.0\bin\php5\ext
    extension=php_curl.dll
    extension=php_mysql.dll
    extension=php_mysqli.dll
    extension=php_pdo.dll
    extension=php_pgsql.dll
    extension=php_soap.dll
    extension=php_sqlite.dll
    zend_extension_ts=C:\Program Files\Zend\ZendStudio_for_i5OS-5.5.0\lib\php5\ZendDebuggerLocal.dll
    zend_debugger.allow_hosts=127.0.0.1/32
    session.save_path=C:\Program Files\Zend\ZendStudio_for_i5OS-5.5.0\tmp
    include_path = C:\Program Files\Zend\ZendStudio_for_i5OS-5.5.0\bin\ZendFramework\library;.

    And this - there is nothing in
    C:\Program Files\Zend\ZendStudio_for_i5OS-5.5.0\bin\phpdocumentator\php.ini

    I was try to add to all this php.ini files
    extension=php_pdo.dll
    extension=php_pdo_sqlite.dll
    extension=php_pdo_mysql.dll

    but doesn't work

    System is:
    Zend Core Version 2.5.0
    PHP Version 5.2.5
    Zend Engine Version 2.2.0
    Server API cgi-fcgi
    PHP Configuration File C:\Program Files\Zend\Core for Oracle\etc\php.ini

    Web Server
    Server Name localhost
    Server Software Apache/2.2.4 (Win32)
    OS Version Microsoft Windows XP

    Server Configuration

    Server Port 80
    Connection Timeout 300
    Keepalive Timeout 300
    Server Root C:\Program Files\Zend\Apache2
    Server Configuration File C:\Program Files\Zend\Apache2\conf\httpd.conf

    Any ideas?
    Thanks,
    rsg

  498. 498 Jon

    Hi Rob

    Excellent job with the tutorial I finally understand what the framework is and does, however I got to page 16 of your tutorial and hit a problem I hit a few earlier but was able to sort out the problems mainly caused by me misspelling a few things but this one has me stumped after getting through the add album section I am having a problem with the edit album section I can change the contents ok but when I hit the Update button I get the following errors

    ------------------------------
    Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'IndexController::20editAction() does not exist and was not trapped in __call()' in C:\wamp\www\zf-tutorial\library\Zend\Controller\Action.php:482 Stack trace: #0 [internal function]: Zend_Controller_Action->__call('20editAction', Array) #1 C:\wamp\www\zf-tutorial\library\Zend\Controller\Action.php(499): IndexController->20editAction() #2 C:\wamp\www\zf-tutorial\library\Zend\Controller\Dispatcher\Standard.php(242): Zend_Controller_Action->dispatch('20editAction') #3 C:\wamp\www\zf-tutorial\library\Zend\Controller\Front.php(929): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #4 C:\wamp\www\zf-tutorial\index.php(30): Zend_Controller_Front->dispatch() #5 {main} thrown in C:\wamp\www\zf-tutorial\library\Zend\Controller\Action.php on line 482
    -----------------------------------
    any thoughts on this would be greatly appreciated

    Best Regards
    Jon

  499. 499 Rob...

    rsg,

    In your web root, create an info.php file with this in it:

    
    <php phpinfo();
    
    

    View the page with a web browser and it'll tell you which php.ini is in use.

    Regards,

    Rob...

  500. 500 Rob...

    Jon,

    At a guess, you have rougue space between '/' and 'edit' when creating a url.

    Regards,

    Rob...

  501. 501 rsg

    Thank you for fast response, i will try to do something with this file,and I hope that it will work:

    Loaded Configuration File
    C:\Program Files\Zend\Core for Oracle\etc\php.ini

    Thanks a lot for this tutorial.

    Thanks,
    rsg

  502. 502 Jon

    Many thanks for the quick response Rob, it was indeed a rougue space on the very first line of _form.phtml
    it was:
    <form action="baseUrl ?>/index/ action; ?>"method="post">
    and should have been:
    <form action="baseUrl ?>/index/action; ?>"method="post">

    after the trailing slash of /index/

    Now it all works fine

    Thanks again
    Jon

  503. 503 Rob...

    Jon,

    Glad that you found it.

    Regards,

    Rob...

  504. 504 Jon

    Hi Rob I have finally completed your tutorial and everything works fine, I am a little concerned about the amount of coding involved to actually use this framework I find myself asking this question does it really save time, now, as you are a PHP Developer in your own right, you can answer this does it only save time on really big projects ?

    Kind Regards
    Jon

  505. 505 Rob...

    Hi Jon,

    We find that it does. Mainly because you don't actually change much code between projects. E.g. the bootstrap code we use is the pretty much same. Also we have created a set of extensions to the framework that automate bits and pieces like setting up layouts and forms to our liking.

    After a while, other stuff gets quite quick too, like setting up models, controllers and view scripts etc as you do it the same way each time.

    Regards,

    Rob...

  506. 506 Jon

    Thanks again for the quick response Rob

    I guess I am still going through a learning curve I would really like to use the framework for my website. at the moment I am actually using (bows head in shame) the joomla cms this was just to speed up deployment of new features and it takes care of the .css for me (I still have to learn more on that subject)but before I did that I originally used dreamweaver for my site and then because it interprets php in its own way (not my way) I ripped the whole site down and re-wrote it using a text editor (in my case Vim) and that took me four days so I think that the zend framework will help but I am not sure how much yet as this is my first look at php frameworks

    Kind Regards

    Jon

  507. 507 Rob...

    *grin*

    Nothing wrong with Joomla - it's a great CMS system. This site uses WordPress for a reason too (laziness on my part)!

    Regards,

    Rob...

  508. 508 Jon

    Hehe Rob :-)

    So should I concentrate on ZF or go back to hand coding everything ? oh by the way my old site can be found at http://www.euadvantage.com/ows that is the one where I re-wrote it using Vim but kept all the clever bits from DW ;) back in the dim and distant past I learned programming using program code and that is what I enjoy rather than these visual languages(although I must admit I am looking at (sorry for swearing) asp.net and yes I would need to learn VB for that :( (whatever happened to gw basic?)

    Kind Regards
    Jon

  509. 509 Jon

    Oh and yes Joomla is a good CMS once I figured out how to run custom coded php pages in it (jumi is your friend)

    Jon

  510. 510 ptoom

    :( I tried version 1.0 of this tutorial 2 days ago. Everything worked from the beginning. Finished the tutorial in no time. It all made sense.

    Tried the newest version today. Nothing works :(
    *sigh*... I hate zfw.

  511. 511 rsg

    Hi Rob,i am grump again :o)

    Now it reads me from data base, but doesn't work any function. Add,delete or edit. If i click on these links its just write:

    Not Found
    The requested URL /zf-tutorial/index/add was not found on this server.

    Ok. i think possibly because add.phtml is into C:\Program Files\Zend\Apache2\htdocs\zf-tutorial\application\views\scripts\index\add.phtml

    so i modify:
    <a href="baseUrl; ?>/application/views/scripts/index/add">Add New Album

    now i get:

    Not Found
    The requested URL /zf-tutorial/application/views/scripts/index/add was not found on this server.

    ok it isn't correct. I must do something else.
    Then i look at the end of tutorial:
    Troubleshooting:
    But i have zf-tutorial in root directory.

    Perhaps what with pdo.dll is not ok?

    ...It isn't obvious for me this Zend framework,...

  512. 512 Rob...

    rsg,

    Enable mod_rewrite for your Apache install.

    Regards,

    Rob...

  513. 513 rsg

    It works :o)

    Thank you very much.

    I must delete:
    php_flag magic_quotes_gpc off
    php_flag register_globals off

    from zf-tutorial/.htaccess

    Now it all in program works fine
    Thanks again
    rsg

  514. 514 ram

    Hi I have been looking out for such type of tutorial, It has helped me immensiley to understand the basics of Zend Frame Work.If you could help me out as how to implement using Ajax Tutorial and how to make use of Zend_Pdf, it will of great help to me...THANKS IN ADVANCE..Have a Great Day!!

  515. 515 Rob...

    Ram,

    You should consider buying the book :)

    Regards,

    Rob...

  516. 516 Charles

    Hello Elisa,
    You solve your problem. I'm happy for you. I would "be more happy" if you would tell us how ? I've got the same problem:
    Uncaught exception 'Zend_Db_Table_Row_Exception' with message 'Specified column "id" is not in the row'

    Regards,
    Charles

  517. 517 Jon

    Hi Rob,

    Having spent some time thinking about this, I have now spent a little money and downloaded your ebook I think I want to re-construct my site using ZF and I think by just doing that will greatly increase me awareness of how this thing works and should eventually leave me in a position to (relatively speaking) easily add updates and and new features to my site

    With Kind Regards

    Jon

  518. 518 Brett

    I did this tutorial locally on XAMPP for Mac & am now trying to move it to my shared hosting(Midphase) for testing. I am now receiving this error. Any ideas would be appreciated.

    Fatal error: Uncaught exception 'Zend_Exception' with message 'At least one error occurred including "Zend/Controller/front.php"; see includeErrors property' in /home/bwpnetwo/public_html/dev/library/Zend/Loader.php:300 Stack trace: #0 /home/bwpnetwo/public_html/dev/library/Zend/Loader.php(93): Zend_Loader::_throwIncludeErrors('Zend/Controller...') #1 /home/bwpnetwo/public_html/dev/index.php(8): Zend_Loader::loadClass('Zend_Controller...') #2 {main} thrown in /home/bwpnetwo/public_html/dev/library/Zend/Loader.php on line 300

  519. 519 Jon

    Ok Hi Brett

    Please do not shoot me down in flames I did notice one thing
    in your path specifiers I noticed /bwpnetwo/
    is that correct or should it be /bwpnetwork/
    just a thought

    with kindest regards
    Jon

  520. 520 Brett

    Thanks for the help Jon,
    bwpnetwo is correct.

  521. 521 Jon

    Ok Brett I kinda thought that but just wanted to check.

    Normally with any spelling errors you get like 17 pages of errors(well maybe not 17 pages but a lot)

  522. 522 Jon

    I have seen this before

    The problem occurs on line 300 of Loader.php

  523. 523 Jon

    Hmm there is no line 300

    Now I am officially confused ;-)

  524. 524 Brett

    This is line 300 of loader.php
    $exception = new Zend_Exception($message);

  525. 525 Piotr czachur

    IndexController.php:67

    $id = (int) ....
    // ...
    if ($id !== false) //will be always true, so this if should be removed/modified.

  526. 526 Rob...

    Piotr,

    Good point :)

    Rob...

  527. 527 Joep

    Great tutorial.
    Thanks for sharing this.

  528. 528 Noury

    Hai Rob.
    Do you want to help me. if i do this:
    class MailerController extends Zend_Controller_Action
    {
    function init()
    {
    }
    function indexAction()
    {
    }
    }
    I get this error: Catchable fatal error: Argument 1 passed to Zend_Controller_Action::__construct() must be an instance of Zend_Controller_Request_Abstract, none given, called in.
    But if i replace function init() by function __construct() i get no error.
    What is better function init() or function __construct().
    Thanks Noury

  529. 529 Rob...

    I suspect you mean the other way around.

    If you override __construct() in your child class, you must give it the same arguments as the parent class and also ensure that you call parent::__construct.

    For this reason, init() is preferred.

    Regards,

    Rob...

  530. 530 Noury

    Hai Rob sorry for my bad english. But i still get the error do you know what is the problem.

    this is my class definition:

    class Admin_CustomersController extends Zend_Controller_Action
    {

    function init()
    {
    }

    function preDispatch()
    {
    }

    function indexAction()
    {
    }
    .
    .
    .
    .

    }

    if i instantiate the class with
    Zend_Loader::loadClass('Admin_CustomersController');
    $this->Admin_CustomersController = new Admin_CustomersController().<-line 10
    I get this error: Catchable fatal error: Argument 1 passed to Zend_Controller_Action::__construct() must be an instance of Zend_Controller_Request_Abstract, none given, called in...on line 10
    thanks for your help.

  531. 531 Rob...

    Noury,

    Why are you instantiating the class yourself?!

    The dispatcher should be doing that for you.

    Regards,

    Rob...

  532. 532 Noury

    because i want to access to loadEmailAction method
    $Emails = $this->Admin_CustomersController->loadEmailsAction();

    Regards
    Noury

  533. 533 Rob...

    Noury,

    The loadEmailsAction() is in the wrong place then, I suspect.

    Regards,

    Rob...

  534. 534 Noury

    Hallo Rob and thanks for your help. I mean if i call and instantiate the class in other class(in this case i call and instantiate the Admin_CustomersController in Admin_NewslettersController)
    then i get the following error:
    Catchable fatal error: Argument 1 passed to Zend_Controller_Action::__construct() must be an instance of Zend_Controller_Request_Abstract, none given, called in
    these are the classes:
    view->baseUrl = $this->_request->getBaseUrl();
    Zend_Loader::loadClass('customers');
    }

    function preDispatch()
    {
    }

    function indexAction()
    {
    }

    function loadCustomersAction()
    {
    }

    function loadCustomerByIdAction($p_ncustomerId)
    {
    }

    function editCustomerAction()
    {
    }

    function loadTodaysCustomersAction()
    {
    }

    function loadLast7DaysCustomersAction()
    {
    }

    function loadLast30DaysCustomersAction()
    {
    }

    function loadEmailsAction()
    {
    }

    function deleteCustomerAction()
    {
    }
    }
    -------------------------------------------

    view->baseUrl = $this->_request->getBaseUrl();

    Zend_Loader::loadClass('Admin_CustomersController');
    $this->Admin_CustomersController = new Admin_CustomersController();
    }

    function preDispatch()
    {
    }

    function indexAction()
    {
    }

    function loadAction()
    {

    }

    function loadNewsletterByIdAction($p_nnewsletterId)
    {
    }

    function sendAction()
    {
    .
    .
    .

    $this->Admin_CustomersController->loadEmailsAction()
    .
    .
    .
    }

    function loadSubscribersEmailsAction()
    {
    }

    function loadUnsubscribersEmailsAction()
    {
    }

    function addAction()
    {
    }

    function editAction()
    {
    }

    function deleteAction()
    {

    }

    }

    Do you know why i get this terrible error
    Thank you very mutch

  535. 535 Rob...

    Noury,

    In general you should never be instantiating a controller class.

    Regards,

    Rob...

  536. 536 Noury

    But how can i access for example to a methode of Admin_CustomersController in other controller for example Admin_NewslettersController.

    Regards,
    Noury

  537. 537 Rob...

    Noury,

    You shouldn't need to. The functionality you are trying to access should probably be in the Model.

    Regards,

    Rob...

  538. 538 Alex

    Hi!
    Excellent tutorial!
    I need some help though...
    I would like to use SQLite instead of MySQL database to build the same application described in this tutorial.
    I've installed SQLite on my computer, I've created the same database manually, and I tried to modify the config.ini file, but I couldn't make it work with Zf.
    Can someone tell me, how to modify the config.ini file to make it work?
    Or is there anything else that should be modified?
    Thanks a lot!

  539. 539 Conrad

    Hey Rib, I was wondering, what's the correct way to setup the

    session.save_path

    At this time, it's commented out and I'm receiving a nasty exception when I attempt to invoke

    Zend_Auth::getInstance()->getIdentity();

    Thanks in advance,

    -Conrad

  540. 540 Conrad

    Hi, I meant Rob in the previous post.

  541. 541 Aad

    Dear Rob,

    As an hobbyist I've followed your great zf tutorial (getting started with zf). I've done this on a stand-alone xampp setup. Sofar i've got a long way. I get all the views and i'm able to add a new record but somehow i don't be able to edit or delete a record. When i try to edit a record, i get this '<br/>' for artist as for title, when i try to delete a record, it just refreshing the page and nomore then that. I gave it a close look to solve it but...

    For sure i want pass you the code, but i've compare it over and over again with your original version and there aren't any differences to find as only, that i gave the root an other name, just to keep it separate from the original one.

    Then, what i'm doing wrong?
    With regards,
    aad

  542. 542 Rob...

    Aad,

    Try viewing the source and reading the notice.

    Regards,

    Rob...

  543. 543 Noury

    Hallo Rob,
    I have add a categoryController in your tutorial, I want every time load deze controller that the app be loaded. How can i do this. if i do this in you index controller i get this error.
    ----------
    Catchable fatal error: Argument 1 passed to Zend_Controller_Action::__construct() must be an instance of Zend_Controller_Request_Abstract, none given, called in D:\www\test_zf_webwinkel-1.0.4-RC1\application\controllers\IndexController.php on line 11 and defined in D:\www\test_zf_webwinkel-1.0.4-RC1\library\Zend\Controller\Action.php on line 123

    ------------

    
    class    IndexController    extends    Zend_Controller_Action 
    {
    
        function init()
        {
        Zend_Loader::loadClass('CategoryController');
    
            $this->CategoryController = new CategoryController();
               $this->view->baseUrl $this->_request->getBaseUrl();
        }
    
        //get homepage content from pages Table
        function indexAction()
        {
        $this->CategoryController->indexAction();  
        Zend_Loader::loadClass('pages');
            $this->view->title 'Home';
        $pagesTbl = new pages();
        $where $pagesTbl->getAdapter()->quoteInto('pagesKey = ?''homepage');//where
            $this->view->homepage $pagesTbl->fetchRow($where);
        }
        
    }
    
    
  544. 544 Aad

    Dear Rob,
    After putting inn some more persistence, i found the needle in the haystack, now it's working :)

    No need to mentioned here, up to the next steps.

    With regards
    Aad

  545. 545 WIL

    Hallo Rob, Do you know why i get this error. everything work on my server but on the server of my provider not.

    Erroe
    -----------------
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, support@one.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

  546. 546 Rob...

    Wil,

    What's in the error log?

    Regards,

    Rob...

  547. 547 Rob...

    Noury,

    use $this->_forward() to run the CategoryController's index action.

    Regards,

    Rob...

  548. 548 zend_fan

    Thank you Akrabat. Your zend tutorial has been very helpful & clear.

  549. 549 neofito

    This is an excellent tutorial, Rob, thanks for it. I need to give an advise to those who post comments here. It is a good idea search for the issue they have, before post any question asking for help. What I did was use the Firefox built in searching capabilities to search for the following set of keywords: 'The requested URL http://localhost/zf-tutorial/index/edit/id/1 was not found on this server' and I found a few topics on this matter. After a couple of minutes mi problem was solved, just by reading someone else solution to the same problem.

    So, the next time, you were looking for help, please make sure to search the entire page, before.

  550. 550 devhash

    I have got the following error .

    Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'Action "displayaddaccountvendor" does not exist and was not trapped in __call()' in /usr/local/Zend/Core/share/ZendFramework-1.5.2/library/Zend/Controller/Action.php:477 Stack trace: #0 /usr/local/Zend/Core/share/ZendFramework-1.5.2/library/Zend/Controller/Action.php(504): Zend_Controller_Action->__call('displayaddaccou...', Array) #1 /usr/local/Zend/Core/share/ZendFramework-1.5.2/library/Zend/Controller/Dispatcher/Standard.php(293): Zend_Controller_Action->dispatch('displayaddaccou...') #2 /usr/local/Zend/Core/share/ZendFramework-1.5.2/library/Zend/Controller/Front.php(914): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #3 /var/www/int/class/Hb/Util/Control/Front.class(65): Zend_Controller_Front->dispatch() #4 /var/www/int/app/index.php(9): Hb_Util_Control_Front::run() #5 {main} thrown in /usr/local/Zend/Core/share/ZendFramework-1.5.2/library/Zend/Controller/Action.php on line 477

    How can i fix this?

  551. 551 Valeriu Zarnescu

    Hi,

    I have only one question:
    Is it possible to load the header and footer files in the index.php file, so they are loaded only once, so when you navigate through the site, only the content is changed, and the header and footer are not refreshed.

    All the best,
    Vali.

    P.S. I like your tutorial, and i saw that you used the same technique like me, loading the header and footer in each html file.

  552. 552 Amit Shah

    This is really a good material for fresh developer.. I have used this for giving my seminar and it helps me a lot...
    Thanks a lot.

  553. 553 tina

    hi
    I already test your code in localhost
    The index.php load ok with the list of albums. But none of the links (add, edit, delete) work for me , message was Page Not Found
    http://localhost/zf-tutorial/index/add

    already set mod_rewrite in httpd.conf uncommented LoadModule rewrite_module modules/mod_rewrite.so and test wiht phpinfo() mod_rewrite is ok can you tell me why ? and Zend Lib already in library ZF-tutorial ?

    but there was error in log apache
    File does not exist: hi
    I already test your code in localhost
    The index.php load ok with the list of albums. But none of the links (add, edit, delete) work for me , message was Page Not Found
    http://localhost:8090/zf-tutorial/index/add

    already set mod_rewrite in httpd.conf uncommented LoadModule rewrite_module modules/mod_rewrite.so and test wiht phpinfo() mod_rewrite is ok can you tell me why ? and Zend Lib already in library ZF-tutorial ?

    but there was error in log apache
    File does not exist: D:/Program Files/Apache Group/Apache2/htdocs/zf-tutorial/index

    and .htaccess file in public directory is empy.

  554. 554 Rob...

    Hi,

    You should probably be using http://akrabat.com/zend-framework-tutorial/ nowadays.

    Regards,

    Rob...

The views expressed in these comments are not the views of the publisher. However, we believe in the rights of others to express their legitimate views and concerns. Any legitimate complaint emailed to rob@akrabat.com will be seriously considered and the post reviewed as desirable and necessary.