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:
- My Subversion repository
- Zip file of tutorial (~9KB)
- Zip file of tutorial including ZF1.0.1 (~2.3MB)
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

August 18th, 2006 at 13:13 #
Thanks for this great tutorial!
greets from germany
ed
August 18th, 2006 at 14:32 #
Great tutorial!
I've been looking for this, and it has helped me tremendously!
August 18th, 2006 at 21:22 #
Great work, thanks :D
August 19th, 2006 at 05:08 #
thank you for the tutorial :)
August 19th, 2006 at 12:14 #
great tutorial, now i want to use zend framework but my hosting have php 4.* :P
thank you for the tutorial :)
August 21st, 2006 at 11:26 #
zip file 1.0.1 does not exist :(
August 21st, 2006 at 21:07 #
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!
August 22nd, 2006 at 05:55 #
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
August 22nd, 2006 at 10:55 #
zip file 1.0.1 does not exist :(
August 22nd, 2006 at 18:51 #
Sorry, but I'm also having trouble with not finding the ZIP... Otherwise, great tutorial!
August 23rd, 2006 at 20:51 #
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.
August 24th, 2006 at 12:24 #
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
August 24th, 2006 at 20:02 #
Carlo,
Do you have a function called addAction() in your IndexController class?
August 28th, 2006 at 04:46 #
Thank you for your excellent tutorial.I'd like to transelate it into Chinese,Can you grant me this privilege?
August 28th, 2006 at 10:28 #
etng,
Please feel free to translate to Chinese, as long as you credit me as the original author.
September 6th, 2006 at 06:12 #
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!
September 6th, 2006 at 20:08 #
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.
September 9th, 2006 at 16:07 #
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.)
September 10th, 2006 at 20:15 #
Thanks for that Holger!
September 11th, 2006 at 16:41 #
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
September 11th, 2006 at 18:43 #
Hi Noury,
Who knows what the future will bring :)
Regards,
Rob...
September 12th, 2006 at 18:00 #
great job!
September 15th, 2006 at 21:46 #
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');
}
September 16th, 2006 at 07:28 #
Noury,
I don't see why not. Obviously, you have to render() both homepageactionTemplate and rubriekenactionTempate from within site.tpl.php.
September 17th, 2006 at 18:51 #
HOlla ROB How are you?
Do you have any idee how i use join() in your tutorial.
Thanks
September 17th, 2006 at 21:40 #
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?
September 18th, 2006 at 09:19 #
Hi Jared,
http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html mentions it at the top.
Regards,
Rob...
September 18th, 2006 at 09:20 #
Noury,
What you do you mean?
Regards,
Rob...
September 20th, 2006 at 08:36 #
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
September 20th, 2006 at 08:38 #
render($this->actionTemplate); ?>
its on page 9. Probably script cut part of line so i put spaces now.
September 20th, 2006 at 15:33 #
Hmm... that's odd as it implies that the actionTemplate variable is empty.
September 27th, 2006 at 15:48 #
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 ?
September 28th, 2006 at 16:37 #
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
October 12th, 2006 at 13:07 #
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)
October 12th, 2006 at 13:18 #
kico,
You need to enable PHP's MySQL extension in the php.ini file.
Regards,
Rob...
October 12th, 2006 at 14:06 #
Rob:
I already did, I'm using WAMP5, that was the first thing i thought too, but still nothing
Regards
October 12th, 2006 at 14:06 #
I'm using ZendStudio 5.1 too
October 12th, 2006 at 14:23 #
kiko,
Have you also enabled the PDO MySQL extension?
Rob...
October 12th, 2006 at 14:28 #
I did that too...
Regards
October 12th, 2006 at 14:51 #
Rob:
I could connect to mysql using prado framework, so the driver works
but still have the same error using Zend
regards
October 12th, 2006 at 17:00 #
problem solved
i just had to restart windows, i don't know what was it, but its fixed
thank you
October 13th, 2006 at 07:24 #
Kico,
That's very odd. Glad it's solved though!
Rob...
October 15th, 2006 at 02:43 #
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
October 15th, 2006 at 12:04 #
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
October 15th, 2006 at 12:10 #
oops, sorry, I've only now found the v1.0.4 :) .. it was too visible to see it, my apologies please
October 15th, 2006 at 18:48 #
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...
October 17th, 2006 at 13:47 #
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...
October 17th, 2006 at 17:50 #
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
October 17th, 2006 at 21:59 #
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
October 18th, 2006 at 07:17 #
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...
October 18th, 2006 at 07:23 #
Tom,
Which page of the tutorial, in which version?
Regards,
Rob...
October 19th, 2006 at 09:21 #
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.
October 19th, 2006 at 09:33 #
Hasan,
You need to ensure that the mysql driver and the PDO mysql driver are enabled in your php.ini.
Regards,
Rob...
October 23rd, 2006 at 15:56 #
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..
October 23rd, 2006 at 16:06 #
Multiple php.ini files in a system can cause a world of pain. Glad you got it sorted!
Regards,
Rob...
October 31st, 2006 at 14:34 #
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.
October 31st, 2006 at 21:54 #
John
Have you tried setting the rewrite base?
$router->setRewriteBase('/zf-tutorial');Regards,
Rob...
November 1st, 2006 at 13:13 #
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.
November 6th, 2006 at 17:50 #
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?
November 6th, 2006 at 19:16 #
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...
November 7th, 2006 at 08:45 #
I still use "deny from all" too ;). Totally unnecessary but it just feels safer, and it does no harm either.
November 7th, 2006 at 15:37 #
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
November 7th, 2006 at 18:59 #
he Rob, you promised us to write a login script with zf.
November 7th, 2006 at 19:42 #
Noury,
I haven't forgotten!
Regards,
Rob...
November 8th, 2006 at 21:42 #
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
November 8th, 2006 at 22:27 #
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.
November 8th, 2006 at 22:42 #
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'],'/'));
November 9th, 2006 at 06:21 #
Hi Matt!
In your index.php you should have included application/models into the include-path with a statement like:
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:
and see if that works.
It still seems that getting the right baseURL is very much system dependant :(
Regards,
Rob...
November 9th, 2006 at 18:04 #
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!
November 13th, 2006 at 10:36 #
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.)
November 13th, 2006 at 19:51 #
Hey Dave,
I just defined a noRouteAction that gives a 404 error.
November 14th, 2006 at 04:52 #
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. :)
November 14th, 2006 at 06:19 #
I think the problem is that there's a bug in the tutorial, right at the bottom of index.php:
should be:
Otherwise, the normal router is used rather than the the rewrite one.
I've updated the PDF and the zip file.
Regards,
Rob...
November 14th, 2006 at 08:23 #
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.
November 16th, 2006 at 10:59 #
Hi!!
Does anything of this tutorial changes with the new zf 0.2 release??
reguards
November 16th, 2006 at 17:01 #
Yes Hasan,
That's why I released a new version :)
Regards,
Rob...
November 20th, 2006 at 22:37 #
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
November 20th, 2006 at 22:39 #
Oops, that code sample did not post very well.
November 21st, 2006 at 06:18 #
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...
November 22nd, 2006 at 06:19 #
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.
November 22nd, 2006 at 06:27 #
Jason,
If I was to guess, I'd say that there's a mod_rewrite problem.
Regards,
Rob...
November 22nd, 2006 at 10:22 #
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.
November 22nd, 2006 at 12:46 #
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
November 22nd, 2006 at 13:33 #
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...
November 22nd, 2006 at 15:43 #
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
November 22nd, 2006 at 19:59 #
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
2.) Add . PATH_SEPARATOR after './application/models'
Thank you for the tutorial!
November 23rd, 2006 at 06:10 #
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.
November 23rd, 2006 at 07:44 #
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.
November 23rd, 2006 at 07:50 #
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.
November 24th, 2006 at 06:45 #
I found http://mysite/index works.
So if index.php can be converted to index somewhere, it will be great.
November 24th, 2006 at 08:11 #
Jason,
Are there any error messages in your Apache error log ?
Regards,
Rob...
November 24th, 2006 at 10:05 #
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
November 24th, 2006 at 14:51 #
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...
November 24th, 2006 at 18:46 #
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
November 25th, 2006 at 08:06 #
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
November 25th, 2006 at 08:55 #
Jason,
Fancy zipping up your project and emailing it to me?
Regards,
Rob...
November 26th, 2006 at 04:31 #
Rob,
I sent it to you.
Thanks.
December 2nd, 2006 at 23:21 #
The Polish translation links, in fact, to the Italian version and vice versa.
December 3rd, 2006 at 08:39 #
Doh!
Thanks R.V! I've updated :)
Regards,
Rob...
December 8th, 2006 at 22:36 #
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
December 9th, 2006 at 08:38 #
Thanks for your kind words, Bruno!
Regards,
Rob...
December 11th, 2006 at 13:57 #
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
December 13th, 2006 at 21:25 #
Dave,
To be hones, I haven't a clue if the current release version is in the tree.
Regards,
Rob...
December 17th, 2006 at 06:44 #
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
December 17th, 2006 at 16:59 #
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!
December 20th, 2006 at 18:02 #
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
December 20th, 2006 at 18:07 #
looks like i sorted it out
It was some syntac errrr
Thnx
December 20th, 2006 at 19:25 #
Pooja,
I'm glad you sorted it!
Regards,
Rob...
December 21st, 2006 at 16:57 #
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
December 21st, 2006 at 19:05 #
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...
December 22nd, 2006 at 10:25 #
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 ?
December 22nd, 2006 at 12:10 #
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...
December 22nd, 2006 at 12:53 #
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.
December 22nd, 2006 at 19:54 #
Hi Abdou,
Did you change __construct() in your index controller to init() as in the svn file ?
Regards,
Rob...
December 22nd, 2006 at 20:46 #
Hi Rob,
The problem is solved now :) i had to change the _construct() of course.
Thank you a lot...
December 22nd, 2006 at 20:58 #
Great news Abdou!
Regards,
Rob...
January 5th, 2007 at 10:19 #
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
January 5th, 2007 at 13:15 #
Great tutorial.. thanks :) it should be included in Zend Framework documents...
this tutorial is clear and explain every detail in every line..
January 5th, 2007 at 13:26 #
Ricardo, do you define the FooController in FooController.php like this one ?
class FooController extends Zend_Controller_Action
January 8th, 2007 at 19:58 #
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?
January 8th, 2007 at 20:34 #
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...
January 11th, 2007 at 03:27 #
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..
January 11th, 2007 at 08:14 #
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...
January 11th, 2007 at 08:27 #
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
January 11th, 2007 at 08:32 #
Thony,
At a guess, you haven't set the path to your models/ directory correctly in index.php.
Regards,
Rob...
January 13th, 2007 at 14:09 #
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.
January 13th, 2007 at 14:11 #
It would seem that I'm having the same problem as Ricardo and anthony.
January 13th, 2007 at 14:17 #
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
January 13th, 2007 at 14:56 #
Hi Kyle,
The Dispatcher has changed in 0.6 and you need to write a front controller plugin to handle this situation.
Regards,
Rob...
January 13th, 2007 at 15:15 #
It seems more like a bug to me than a feature I need to add back in myself.
January 13th, 2007 at 15:50 #
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.
January 13th, 2007 at 15:53 #
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...
January 13th, 2007 at 16:40 #
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.
January 13th, 2007 at 19:02 #
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.
January 13th, 2007 at 19:09 #
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...
January 13th, 2007 at 21:11 #
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.
January 14th, 2007 at 17:42 #
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...
January 15th, 2007 at 03:12 #
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
January 15th, 2007 at 03:13 #
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'
January 15th, 2007 at 09:38 #
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...
January 15th, 2007 at 11:56 #
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
January 15th, 2007 at 12:03 #
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
January 16th, 2007 at 04:50 #
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
January 16th, 2007 at 06:00 #
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...
January 16th, 2007 at 06:04 #
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...
January 16th, 2007 at 22:53 #
thank you for the tutorial
Great work!
January 23rd, 2007 at 16:27 #
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
January 29th, 2007 at 18:57 #
Any future release of the tutorial for the 0.7.0 release of the ZendFramework?
January 29th, 2007 at 19:10 #
Good point!
I'm nearly sure that it works "as is" with 0.7, but I'd better test ;)
Regards,
Rob...
January 31st, 2007 at 13:05 #
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
February 7th, 2007 at 10:41 #
Hi,
After i copied 'Zend' folder and Zend.php to zf-tutorial\library\
tutorial is working fine :-)
thanks
San.
February 7th, 2007 at 12:29 #
Hi San,
Glad to hear it!
Regards,
Rob...
February 7th, 2007 at 22:55 #
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!
February 13th, 2007 at 03:26 #
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..
February 13th, 2007 at 06:27 #
Hi Baugus,
What's the URL that you are trying to access?
Regards,
Rob...
February 14th, 2007 at 04:13 #
192.168.0.1/oprekzend/index.php
February 14th, 2007 at 06:30 #
Bagus,
I think that the base url is not being set to the correct value.
Try adding:
After:
in index.php.
Regards,
Rob...
February 15th, 2007 at 04:06 #
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 ?
February 15th, 2007 at 08:28 #
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...
February 15th, 2007 at 15:00 #
English version has incorrect link to old 1.2.2.
February 15th, 2007 at 16:26 #
Thanks glumac!
Fixed.
Regards,
Rob...
February 16th, 2007 at 01:45 #
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
February 16th, 2007 at 19:44 #
Rob,
Can you please tell me why you didn't approve my posting?
thanks,
-Ali
February 16th, 2007 at 20:18 #
Hi Ali,
Probably because I pressed the wrong button! I've approved it now. Sorry!
Regards,
Rob...
February 23rd, 2007 at 15:05 #
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
February 26th, 2007 at 13:24 #
Great work. Looking forward to a 0.8 update ;-)
February 26th, 2007 at 22:42 #
ok, for ZF 0.8 :
(It's not a bug, it's a feature)! Zend_Controller_RewriteRouter was renamed to Zend_Controller_Router_Rewrite.
March 5th, 2007 at 04:22 #
Glen,
Where do I use Zend_Controller_RewriteRouter in the tutorial?
Regards,
Rob...
March 5th, 2007 at 04:23 #
christian,
Missing indexController.php or permissions problem?
Regards,
Rob...
March 5th, 2007 at 09:21 #
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!
March 5th, 2007 at 14:14 #
Christian,
ah! done that too :(
Regards,
Rob...
March 7th, 2007 at 17:00 #
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
March 7th, 2007 at 21:13 #
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...
March 18th, 2007 at 18:20 #
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.
March 18th, 2007 at 19:45 #
And then I find this article... doh!
http://akrabat.com/2007/03/10/goodbye-zendphp/
Once again, thanks for all your work and help.
March 18th, 2007 at 19:51 #
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...
March 21st, 2007 at 16:16 #
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é
March 21st, 2007 at 21:39 #
How bout 0.9.0 Beta MVC tutorial?
March 22nd, 2007 at 01:02 #
Look up just above your comments to #176, guys. He is working on a 0.9.0 version and it will be out shortly.
March 22nd, 2007 at 16:45 #
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...
March 22nd, 2007 at 16:50 #
How to get the source code??? how to use these SVN stuff?
March 24th, 2007 at 04:25 #
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?
March 24th, 2007 at 09:03 #
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/
March 24th, 2007 at 14:14 #
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...
March 24th, 2007 at 17:20 #
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).
March 24th, 2007 at 18:22 #
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!
March 24th, 2007 at 18:57 #
Scott,
Great - I'm glad 27 fixed that one!.
With any luck 28 fixes the include path issue.
Regards,
Rob...
March 25th, 2007 at 02:10 #
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.
March 25th, 2007 at 07:43 #
The best Tutorial. This should be included in zend as the official tutorial.
March 26th, 2007 at 10:28 #
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
March 27th, 2007 at 18:10 #
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.
March 29th, 2007 at 06:22 #
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.
March 29th, 2007 at 06:41 #
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...
March 29th, 2007 at 07:50 #
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();
}
March 29th, 2007 at 08:02 #
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
March 29th, 2007 at 14:27 #
Thanks Rob! Superb tutorial that's easy to follow. Cheers.
March 29th, 2007 at 16:52 #
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?
March 29th, 2007 at 18:30 #
Brian,
Is your Apache set up to use .phtml as a PHP file?
Regards,
Rob...
March 29th, 2007 at 18:31 #
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...
March 29th, 2007 at 18:42 #
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).
March 29th, 2007 at 23:31 #
Hi Rob
Just to let you know - I found the problem, it was 1 extra line of space before my opening
March 31st, 2007 at 13:57 #
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!
March 31st, 2007 at 22:22 #
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. ;)
April 1st, 2007 at 19:43 #
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:
Regards,
Rob...
April 1st, 2007 at 19:59 #
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
April 4th, 2007 at 09:00 #
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.
April 4th, 2007 at 09:08 #
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!
April 4th, 2007 at 18:11 #
Ven,
Possibly related to xampp? I have no idea though!
Regards,
Rob...
April 8th, 2007 at 00:42 #
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
April 8th, 2007 at 01:08 #
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.
April 12th, 2007 at 10:09 #
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?
April 12th, 2007 at 12:11 #
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.
April 12th, 2007 at 12:48 #
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');
...
...
April 12th, 2007 at 12:58 #
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
April 12th, 2007 at 15:27 #
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/
April 12th, 2007 at 18:46 #
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...
April 12th, 2007 at 18:50 #
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...
April 15th, 2007 at 19:23 #
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
April 16th, 2007 at 06:07 #
nour,
More information than "it dont work" would be useful...
Regards,
Rob...
April 16th, 2007 at 17:56 #
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();
}
}
April 16th, 2007 at 18:11 #
Nour,
What is the initial definition of class ShippingmethodsController() ?
Regards,
Rob...
April 16th, 2007 at 18:16 #
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;
}
}
April 17th, 2007 at 16:12 #
Man, this is impressive!
Excelent writting and aproach of teaching.
2 thumbs up!
April 17th, 2007 at 16:59 #
hai rob i m waiting for your hulp
April 17th, 2007 at 18:41 #
DJIO,
Thanks :)
Regards,
Rob...
April 17th, 2007 at 18:42 #
nour,
Is ShippingmethodsController extending Zend_Controller_Action?
Regards,
Rob...
April 18th, 2007 at 16:20 #
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;
}
}
April 18th, 2007 at 16:22 #
Yes this is is:
class ShippingmethodsController extends Zend_Controller_Action
{
}
April 18th, 2007 at 22:16 #
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?
April 18th, 2007 at 22:21 #
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...
April 19th, 2007 at 12:20 #
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)
April 19th, 2007 at 22:26 #
No joy this evening with the PDO_SQLITE or MySQLi.
Has anyone managed to get those adapters working with your tutorial?
April 20th, 2007 at 08:26 #
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.
April 20th, 2007 at 19:03 #
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...
April 22nd, 2007 at 08:19 #
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?
April 24th, 2007 at 06:22 #
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?
April 24th, 2007 at 19:06 #
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');
April 24th, 2007 at 20:14 #
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;
April 25th, 2007 at 05:38 #
nour,
No idea bout what namespace Zend_Auth uses.
You could certainly place your getIdentity call in the bootstrap though.
Regards,
Rob...
April 25th, 2007 at 05:41 #
Jude,
I am sure that using a for loop rather than a foreach will not make any difference.
Regards,
Rob...
April 26th, 2007 at 18:29 #
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!
April 26th, 2007 at 20:23 #
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?
April 26th, 2007 at 20:28 #
Nick,
Thanks for your kind words. I'm glad it helped you.
Regards,
Rob...
April 26th, 2007 at 20:29 #
miguelp,
Check that you have AllowOverride All set in your httpd.conf file.
Regards,
Rob...
April 26th, 2007 at 20:36 #
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.
April 27th, 2007 at 20:48 #
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
April 30th, 2007 at 05:16 #
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
April 30th, 2007 at 06:08 #
Luke,
Interesting.
Thanks!
Rob...
April 30th, 2007 at 09:35 #
Luke,
I'll try your SQLite settings out tonight.
Thanx in advance.
Rushy
April 30th, 2007 at 09:38 #
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
May 3rd, 2007 at 01:02 #
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,
May 3rd, 2007 at 02:27 #
And the spanish version, mi hermano?
May 3rd, 2007 at 04:40 #
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,
May 3rd, 2007 at 04:59 #
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.
May 7th, 2007 at 18:07 #
Thanks for the tip, prebugged!
Regards,
Rob...
May 8th, 2007 at 08:09 #
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.
May 8th, 2007 at 18:56 #
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
May 8th, 2007 at 22:26 #
Thanks for your kind words Stig. I'm glad you found it useful.
Regards,
Rob...
May 9th, 2007 at 08:03 #
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?
May 9th, 2007 at 08:06 #
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
May 9th, 2007 at 08:20 #
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.
May 9th, 2007 at 08:39 #
Hi Stig,
It sounds like album hasn't been assigned to the view from the controller action.
Regards,
Rob...
May 9th, 2007 at 10:32 #
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
May 9th, 2007 at 11:46 #
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!
May 9th, 2007 at 11:50 #
Stig,
Glad you sorted it!
Regards,
Rob...
May 9th, 2007 at 13:50 #
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
May 10th, 2007 at 08:37 #
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.
May 10th, 2007 at 09:32 #
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
May 10th, 2007 at 14:00 #
Johnny,
Is your local .htaccess file being used and have you enabled mod_rewrite in httpd.conf?
Regards,
Rob...
May 10th, 2007 at 21:12 #
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
May 12th, 2007 at 13:08 #
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.
May 12th, 2007 at 13:10 #
index.phtml of course
May 12th, 2007 at 14:26 #
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
May 13th, 2007 at 04:32 #
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.
May 13th, 2007 at 05:29 #
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.
May 13th, 2007 at 15:01 #
Ravi,
Thank you for your kind words. I'm glad you've got it going.
Regards,
Rob...
May 13th, 2007 at 15:01 #
Johnny,
Glad you sorted it!
Regards,
Rob...
May 13th, 2007 at 16:39 #
Hi,
How do I use custom helpers in your example?
May 25th, 2007 at 22:17 #
Great tutorial!
Small spelling mistake on page 5 (version 1.3.4) ... it's "Organizing", not "Organising".
May 27th, 2007 at 20:44 #
Nate,
I'm British...
Regards,
Rob...
May 30th, 2007 at 13:32 #
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
May 30th, 2007 at 21:30 #
@Andrew
Just try the new ViewRenderer:
http://devzone.zend.com/node/view/id/2072
May 30th, 2007 at 21:49 #
Yes. I need to update the tutorial to handle the new ViewRenderer action helper.
Just need to find some time!
Regards,
Rob...
May 31st, 2007 at 04:59 #
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?
June 1st, 2007 at 05:47 #
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
June 1st, 2007 at 20:29 #
Jordan,
I'm not totally surprised as 1.0RC introduced a few changes.
Regards,
Rob...
June 1st, 2007 at 21:41 #
Jordan,
I take it back - that error is something else. You should have
not
in your .phtml files.
Regards,
Rob...
June 3rd, 2007 at 21:09 #
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 ;-)
June 4th, 2007 at 11:56 #
Chris,
Thanks! I'm glad you've found it helpful.
Regards,
Rob...
June 6th, 2007 at 04:25 #
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
June 6th, 2007 at 05:54 #
Hi Jorge,
Thanks.
I didn't realise that I had used Zend_Debug anywhere!
Regards,
Rob...
June 7th, 2007 at 09:09 #
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 ?
June 7th, 2007 at 11:10 #
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" >_
June 7th, 2007 at 11:27 #
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 :'(
June 8th, 2007 at 17:26 #
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 ...
June 8th, 2007 at 18:31 #
Bastien,
I'm glad you sorted it!
Regards,
Rob...
June 8th, 2007 at 23:56 #
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 ?
June 9th, 2007 at 07:30 #
What does your error log file say?
Regards,
Rob...
June 9th, 2007 at 17:30 #
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.
June 10th, 2007 at 05:51 #
->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.
June 10th, 2007 at 14:05 #
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...
June 10th, 2007 at 20:14 #
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
June 10th, 2007 at 21:12 #
Hi again.
I'm sorry, my previous post was wrong - the "dirname()" part, not the "excellent tutorial part :)
Regards
Allan
June 12th, 2007 at 02:42 #
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.
June 12th, 2007 at 15:46 #
How can I get the ID of the recordset, which is saved? I need it for saving informations into another table.
Regards,
Daniel
June 12th, 2007 at 21:26 #
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...
June 13th, 2007 at 07:30 #
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
June 13th, 2007 at 07:52 #
Problem solved!
I didn't put the id in the url:
http://localhost/index/edit/id/1
----------------------------^
(stupid!)
Regards,
Peter
June 13th, 2007 at 10:50 #
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}
June 13th, 2007 at 10:56 #
I think error with the following statement..
$post = Zend::registry('post');
thanks
San.
June 13th, 2007 at 17:33 #
San,
Have you read through the latest version of the Tutorial?
Regards,
Rob...
June 15th, 2007 at 12:00 #
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();
June 18th, 2007 at 06:14 #
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...
June 18th, 2007 at 10:57 #
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
June 18th, 2007 at 11:00 #
Sorry, the last line of code in the above should read:
echo $this->escape($val['title'])
June 18th, 2007 at 16:49 #
Jude,
You should be able to do:
Regards,
Rob...
June 18th, 2007 at 18:36 #
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
June 21st, 2007 at 14:04 #
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
June 22nd, 2007 at 05:14 #
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...
June 24th, 2007 at 20:10 #
Wow. That was so cool - all of a sudden I could manage this CD catalogue. Really, really good tutorial. Thanks!
June 28th, 2007 at 06:23 #
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?
June 28th, 2007 at 10:25 #
I had similar problems with RC3. I switched to using the latest nightly snapshot and everything worked fine again.
June 28th, 2007 at 11:37 #
thanks Bryan
July 3rd, 2007 at 07:09 #
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
July 3rd, 2007 at 07:29 #
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...
July 3rd, 2007 at 18:12 #
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
July 11th, 2007 at 18:06 #
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?
July 11th, 2007 at 18:11 #
I used the fix posted above by Thiago Melo de Paula, and it worked. Now I can continue with the tutorial.
July 12th, 2007 at 09:56 #
Yep - page 6 doesn't make sense any more. I'll have to revise that section completely!
Regards,
Rob...
July 12th, 2007 at 11:39 #
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!
July 12th, 2007 at 22:26 #
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());
July 12th, 2007 at 22:30 #
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!
July 17th, 2007 at 10:12 #
Thanks Jgreen, I thoough view means a view Object,seems not
July 17th, 2007 at 11:07 #
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...
July 18th, 2007 at 08:34 #
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.
July 19th, 2007 at 00:31 #
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
July 19th, 2007 at 11:35 #
@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?
July 19th, 2007 at 11:36 #
@Rob: thanks for linking me in :)
July 19th, 2007 at 15:05 #
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.
July 19th, 2007 at 18:58 #
Hi Axex!
Thanks very much for your effort.
Regards,
Rob...
July 20th, 2007 at 02:41 #
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!
July 20th, 2007 at 13:12 #
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.
July 20th, 2007 at 15:49 #
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.
July 20th, 2007 at 20:37 #
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 :)
July 20th, 2007 at 23:48 #
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
July 21st, 2007 at 05:42 #
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...
July 21st, 2007 at 05:43 #
terac,
Look at Two-Step views.
Regards,
Rob...
July 21st, 2007 at 05:44 #
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...
July 21st, 2007 at 05:45 #
kang,
What url are you trying to access?
Regards,
Rob...
July 21st, 2007 at 11:48 #
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.
July 21st, 2007 at 11:49 #
phpdummi,
Glad you sorted it :)
Regards,
Rob...
July 22nd, 2007 at 09:41 #
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
July 22nd, 2007 at 13:04 #
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...
July 22nd, 2007 at 13:55 #
phpdummi: Nothing happens. I get clean white page.
July 22nd, 2007 at 13:57 #
phpdummi: I tried to make mistake or hide Zend folder. No change.
July 22nd, 2007 at 18:47 #
Mingan,
Try turning on display_errors and setting error_reporting to E_ALL in your php.ini
Regards,
Rob...
July 23rd, 2007 at 09:59 #
Problem solved, PHP loaded different php.ini (with display_errors = off) file that I edited. Thank you very much
July 23rd, 2007 at 17:06 #
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
July 23rd, 2007 at 22:27 #
Great tutorial ... hats off..
July 25th, 2007 at 13:22 #
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:
July 25th, 2007 at 13:26 #
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
July 26th, 2007 at 05:30 #
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.
July 26th, 2007 at 05:38 #
There's a better way now as you can use nowadays.
Regards,
Rob...
July 26th, 2007 at 10:07 #
Thanks for this tutorial!
July 31st, 2007 at 07:59 #
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?
July 31st, 2007 at 08:04 #
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?
July 31st, 2007 at 08:36 #
Never mind my message above (#365), I already found the problem...
typo... doh!
Greetz,
Wizz
August 1st, 2007 at 03:44 #
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.
August 2nd, 2007 at 15:27 #
@ 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?
August 3rd, 2007 at 21:59 #
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).
August 5th, 2007 at 00:17 #
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.
August 10th, 2007 at 14:02 #
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?
August 10th, 2007 at 14:07 #
Christian,
How about
Regards,
Rob...
August 10th, 2007 at 14:16 #
oh that was pretty straight forward :) why didnt i think of that!
thanks! :) your a time saver!
August 11th, 2007 at 00:30 #
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
August 11th, 2007 at 15:59 #
solved the problem: footer.phtml was mis-spelled as footer.html!!!
August 11th, 2007 at 16:18 #
"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.
August 11th, 2007 at 18:08 #
Balu,
Doh!
Good catch!
Regards,
Rob...
August 14th, 2007 at 13:19 #
please do changes to $config->db->config->asArray())
=>
$config->db->config->toArray())
August 14th, 2007 at 20:48 #
gforce,
I thought that was corrected! Which version of the tutorial are you reading?
Regards,
Rob...
August 15th, 2007 at 07:27 #
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
August 15th, 2007 at 18:12 #
Thanks, Trond,
I'm glad you found it useful.
Regards,
Rob...
August 16th, 2007 at 00:42 #
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.
August 16th, 2007 at 07:43 #
Dave,
The %20 character is a space that's encoded.
Regards,
Rob...
August 16th, 2007 at 18:56 #
I finally found a tutorial that follow my personal favorite rule for programming: KISS!
Congratulations.
August 17th, 2007 at 00:00 #
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.
August 18th, 2007 at 02:10 #
Referencing #383 & 386, I found that I didn't have the closing quote on the form action.
Rob, keep up the good work.
August 18th, 2007 at 20:48 #
Dave,
I'm glad you sorted it!
Regards,
Rob...
August 18th, 2007 at 20:49 #
Peterson,
I'm glad you found it useful.
Rob...
August 19th, 2007 at 21:33 #
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.
August 19th, 2007 at 23:52 #
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
August 20th, 2007 at 21:39 #
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."
August 21st, 2007 at 05:00 #
Pyko , Jeff,
Either mod-rewrite isn't enabled or you haven't enabled use of .htaccess files.
Regards,
Rob...
August 23rd, 2007 at 07:18 #
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
August 25th, 2007 at 10:23 #
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.
August 28th, 2007 at 03:22 #
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)
August 28th, 2007 at 07:14 #
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
August 28th, 2007 at 07:50 #
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
August 29th, 2007 at 16:39 #
Thanks Steve! So (false !== false) is false, right?
August 30th, 2007 at 21:46 #
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?
September 2nd, 2007 at 07:23 #
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?
September 2nd, 2007 at 09:01 #
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...
September 5th, 2007 at 09:01 #
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. :-)
September 6th, 2007 at 22:12 #
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!!
September 14th, 2007 at 10:04 #
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?
September 14th, 2007 at 11:05 #
kojot,
Look up the request object's baseUrl() function.
Regards,
Rob...
September 14th, 2007 at 11:31 #
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.
September 15th, 2007 at 05:57 #
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
September 15th, 2007 at 06:00 #
nice filtering :-)
one more time ... use
type="submit" name="?php echo $this->escape($this->action); ?"
instead of
type="submit" name="add"
September 15th, 2007 at 06:49 #
Adrian,
Maybe. As we don't test for the submit button in the code, what benefit would it bring?
Regards,
Rob...
September 16th, 2007 at 20:03 #
Thanks for this tutorials, it may help me much more.
^^
September 17th, 2007 at 13:42 #
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
September 17th, 2007 at 18:52 #
Forgett my before mail!!! I can solve it!!!
Your tutorial is fantastic! Thanks very much !!!
September 17th, 2007 at 19:03 #
Hello
Very interesting information! Thanks!
Bye
September 18th, 2007 at 21:29 #
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
September 20th, 2007 at 10:49 #
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!!!
September 21st, 2007 at 06:38 #
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 :)
September 21st, 2007 at 17:42 #
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
September 22nd, 2007 at 20:37 #
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...
September 22nd, 2007 at 20:46 #
Thanks for the heads-up Jeremy!
Regards,
Rob...
September 26th, 2007 at 17:02 #
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.
October 1st, 2007 at 12:32 #
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!
October 1st, 2007 at 14:15 #
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.
October 1st, 2007 at 14:25 #
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
>.
October 1st, 2007 at 17:02 #
Daniel,
Thanks :)
(Can you tell that I come from a C background?!)
Regards,
Rob...
October 1st, 2007 at 17:03 #
milunes,
As you have seen, if your project is at the top of a vhost, then the base url is blank.
Regards,
Rob...
October 8th, 2007 at 15:36 #
Very Nice Work!
It help very much to start with ZF 1.0.0
Thank You
October 13th, 2007 at 01:18 #
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
October 13th, 2007 at 09:08 #
Zend Framework has unveiled the version 1.0.2, I hope your tutorial code can also upgraded.
huangam
October 13th, 2007 at 11:57 #
Huangam,
It should work fine with 1.0.2.
Regards,
Rob...
October 15th, 2007 at 20:42 #
Brilliant,
Thank you so much, the tutorial was a great way to get started with ZF.
October 21st, 2007 at 19:19 #
Thank for example
October 29th, 2007 at 03:14 #
Good Job here. It helped me get started with ZF. Thanks!
November 3rd, 2007 at 21:33 #
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
November 4th, 2007 at 20:32 #
Dinesh,
If I was to guess, I'd say that you have a problem with htaccess rules.
Regards,
Rob...
November 6th, 2007 at 22:27 #
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
November 6th, 2007 at 22:33 #
Never mind.. Found the part saying there should be a fatal error.
November 7th, 2007 at 07:43 #
Hi EllisGL,
I would set the zend.ze1_compatibility_mode setting in your php.ini too!
Rob...
November 7th, 2007 at 22:17 #
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.
November 8th, 2007 at 10:24 #
Hi Rob,
Thanks for the pointer.
I will check the htaccess rules.
Best regards,
Dinesh.
November 8th, 2007 at 12:39 #
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.
November 8th, 2007 at 22:12 #
Hi Agustin,
Excellent! I've just started playing with the MYSQLI adapter myself.
Regards,
Rob...
November 13th, 2007 at 01:50 #
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!
November 13th, 2007 at 05:59 #
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...
November 13th, 2007 at 06:16 #
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
November 13th, 2007 at 08:08 #
Hi Jay,
Double check the spelling of the deleteAction() function which should be in the IndexController class.
Regards
Rob...
November 14th, 2007 at 02:41 #
Rob,
Great tutorial. I sent you an email before finding this page.
Thanks,
November 14th, 2007 at 15:50 #
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.
November 14th, 2007 at 16:42 #
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.
November 15th, 2007 at 12:25 #
It's a very great intro tutorial. If you extend it with some functionality required modular structure and authentication you will be the best ;-)
November 16th, 2007 at 15:48 #
Great tutorial, thank you very much!
November 23rd, 2007 at 13:33 #
Great tutorial!
Thank you very much, slowly i understand how to use this damned framework ;)
November 23rd, 2007 at 19:54 #
I'm glad the tutorial is still helpful to you guys!
Regards,
Rob...
November 25th, 2007 at 08:52 #
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
November 25th, 2007 at 21:11 #
Bart,
You need:
Doesn't give you an assoc type output; you need Zend_Db for that.
Regards,
Rob...
November 28th, 2007 at 21:24 #
Hi.
Good design, who make it?
November 29th, 2007 at 08:17 #
naisioxerloro,
I did :) Which is one reason why it is simple...
Regards,
Rob...
November 29th, 2007 at 08:31 #
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
November 30th, 2007 at 14:06 #
How do you add a simple and not have it redirected to the same site?
November 30th, 2007 at 14:07 #
Sorry....how do you add a simple..
a href=www.example.com without it being redirected to the index.
November 30th, 2007 at 18:09 #
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.
November 30th, 2007 at 18:17 #
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...
November 30th, 2007 at 18:58 #
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()
{
...
}
}
December 3rd, 2007 at 19:36 #
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????
December 5th, 2007 at 23:53 #
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
December 6th, 2007 at 08:13 #
Frank,
Sorry - I have no idea :(
Regards,
Rob...
December 6th, 2007 at 08:13 #
Hi Matthew!
I'm glad you found it useful.
Regards,
Rob...
December 6th, 2007 at 22:45 #
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'. ;)
December 6th, 2007 at 22:46 #
It seems you don't allow PHP code in the comments. I'll send you an email.
December 7th, 2007 at 08:13 #
Sorry Mathew!
I don't see why you aren't allowed to do PHP code though...
Regards,
Rob...
December 7th, 2007 at 16:07 #
The first code block is what I was trying to do.
http://hudzilla.org/phpwiki/index.php?title=Opening_and_closing_code_islands
December 9th, 2007 at 14:39 #
Latvian translation of 1.4.5 available at:
http://webtech.lv/rakstu-darbi/zend-framework/
December 17th, 2007 at 09:15 #
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
December 17th, 2007 at 09:46 #
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...
December 17th, 2007 at 13:57 #
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
December 20th, 2007 at 20:14 #
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
December 21st, 2007 at 09:10 #
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...
December 21st, 2007 at 10:26 #
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?
December 21st, 2007 at 10:31 #
Hi Bevan,
At a guess, the .htaccess file is missing in the public subdirectory.
Regards,
Rob...
December 31st, 2007 at 03:41 #
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
December 31st, 2007 at 09:53 #
elis,
I'm not sure what you mean. I would use the formSelect() view helper personally.
Regards,
Rob...
January 4th, 2008 at 04:42 #
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
January 12th, 2008 at 03:12 #
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!
January 12th, 2008 at 03:13 #
""
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.
January 23rd, 2008 at 08:49 #
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 :)
January 30th, 2008 at 11:37 #
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.
February 2nd, 2008 at 22:55 #
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()
February 2nd, 2008 at 23:01 #
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...
February 6th, 2008 at 20:50 #
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();
February 7th, 2008 at 19:33 #
Tanks Rob ihave found it:
$this->getRequest()->getModuleName()
February 16th, 2008 at 09:25 #
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.
February 16th, 2008 at 17:56 #
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
February 16th, 2008 at 19:26 #
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...
February 17th, 2008 at 00:12 #
Thx for the quick reply. That makes perfect sense and helps me quite a bit.
thx again, Keith
February 18th, 2008 at 16:01 #
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
February 19th, 2008 at 13:47 #
Joe,
What do you get if you navigate directly to a CSS file?
Rob...
February 22nd, 2008 at 14:02 #
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
February 24th, 2008 at 23:19 #
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
February 25th, 2008 at 05:59 #
rsg,
In your web root, create an info.php file with this in it:
View the page with a web browser and it'll tell you which php.ini is in use.
Regards,
Rob...
February 25th, 2008 at 06:00 #
Jon,
At a guess, you have rougue space between '/' and 'edit' when creating a url.
Regards,
Rob...
February 25th, 2008 at 06:15 #
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
February 25th, 2008 at 14:23 #
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
February 25th, 2008 at 19:44 #
Jon,
Glad that you found it.
Regards,
Rob...
February 25th, 2008 at 20:37 #
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
February 25th, 2008 at 20:52 #
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...
February 25th, 2008 at 21:09 #
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
February 25th, 2008 at 21:13 #
*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...
February 25th, 2008 at 21:23 #
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
February 25th, 2008 at 21:28 #
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
February 26th, 2008 at 01:42 #
:( 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.
February 27th, 2008 at 07:06 #
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,...
February 27th, 2008 at 07:50 #
rsg,
Enable mod_rewrite for your Apache install.
Regards,
Rob...
February 27th, 2008 at 11:52 #
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
February 28th, 2008 at 04:41 #
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!!
February 28th, 2008 at 09:49 #
Ram,
You should consider buying the book :)
Regards,
Rob...
February 28th, 2008 at 14:03 #
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
February 28th, 2008 at 20:54 #
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
February 28th, 2008 at 22:10 #
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
February 28th, 2008 at 22:52 #
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
February 28th, 2008 at 23:01 #
Thanks for the help Jon,
bwpnetwo is correct.
February 28th, 2008 at 23:06 #
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)
February 28th, 2008 at 23:08 #
I have seen this before
The problem occurs on line 300 of Loader.php
February 28th, 2008 at 23:25 #
Hmm there is no line 300
Now I am officially confused ;-)
February 28th, 2008 at 23:37 #
This is line 300 of loader.php
$exception = new Zend_Exception($message);
February 29th, 2008 at 11:05 #
IndexController.php:67
$id = (int) ....
// ...
if ($id !== false) //will be always true, so this if should be removed/modified.
March 1st, 2008 at 09:43 #
Piotr,
Good point :)
Rob...
March 6th, 2008 at 22:55 #
Great tutorial.
Thanks for sharing this.
March 9th, 2008 at 18:25 #
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
March 9th, 2008 at 19:23 #
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...
March 9th, 2008 at 19:40 #
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.
March 9th, 2008 at 20:14 #
Noury,
Why are you instantiating the class yourself?!
The dispatcher should be doing that for you.
Regards,
Rob...
March 9th, 2008 at 20:24 #
because i want to access to loadEmailAction method
$Emails = $this->Admin_CustomersController->loadEmailsAction();
Regards
Noury
March 9th, 2008 at 21:04 #
Noury,
The loadEmailsAction() is in the wrong place then, I suspect.
Regards,
Rob...
March 10th, 2008 at 20:09 #
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
March 10th, 2008 at 20:17 #
Noury,
In general you should never be instantiating a controller class.
Regards,
Rob...
March 10th, 2008 at 20:41 #
But how can i access for example to a methode of Admin_CustomersController in other controller for example Admin_NewslettersController.
Regards,
Noury
March 10th, 2008 at 21:11 #
Noury,
You shouldn't need to. The functionality you are trying to access should probably be in the Model.
Regards,
Rob...
March 11th, 2008 at 06:21 #
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!
March 12th, 2008 at 06:47 #
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
March 12th, 2008 at 06:49 #
Hi, I meant Rob in the previous post.
March 16th, 2008 at 08:56 #
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
March 16th, 2008 at 11:29 #
Aad,
Try viewing the source and reading the notice.
Regards,
Rob...
March 16th, 2008 at 12:07 #
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
------------
March 16th, 2008 at 14:29 #
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
March 16th, 2008 at 15:47 #
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.
March 16th, 2008 at 17:17 #
Wil,
What's in the error log?
Regards,
Rob...
March 16th, 2008 at 17:18 #
Noury,
use $this->_forward() to run the CategoryController's index action.
Regards,
Rob...
March 17th, 2008 at 05:43 #
Thank you Akrabat. Your zend tutorial has been very helpful & clear.
April 1st, 2008 at 01:57 #
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.
September 4th, 2008 at 05:39 #
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?
September 18th, 2008 at 16:48 #
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.
November 6th, 2008 at 14:11 #
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.
November 13th, 2008 at 23:15 #
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.
November 14th, 2008 at 08:11 #
Hi,
You should probably be using http://akrabat.com/zend-framework-tutorial/ nowadays.
Regards,
Rob...