‘noViewRendered’ will result in ‘viewRendered’
My buddy Zachary sent me an email today pointing out these two bits of errata.
On page 13, a line of code is missing:
Zend_Loader::registerAutoload();
On page 22 is the following paragraph:
If you followed the instructions in the last chapter then you already have most of
what we need to make this work. However, we do have three changes to make.
First, open your bootstrap file (index.php) and remove the line:$frontController->setParam('noViewRendered', true);We will be using view scripts to handle the output in this sample.
The parameter should be ‘noViewRenderer’.
$frontController->setParam('noViewRenderer', true);
Both of these are correct in the sample code but incorrect in the final manuscript.
Thanks Zachary!
=C=
Reader's Comments
Well, I’m glad I found this post, since this was my entire problem in setting up the bootstrap.
I think the book is wonderful, it has a very logical approach to learning MVC and ZF. There are things that I am stumbling upon, and this was one of them. One thing that I wish you would do is to correct the E-book pdf that is out there already. Since it is unpublished in printed form, could you incorporate your errata in there?
Also, while trying to get the yahoo keyword example going, my installation of PHP is having problems in parsing the header on the first line. It is trying to read it like php in the extract.phtml file and the index.phtml file. Is there anything I can do about this?
Learning a lot,
CharlesH
Hi Charles!
Thanks for writing.
1: Republishing the PDF. I wish I could but that decision is not up to me, it’s up to the publisher.
2: You’ve probably got “short tags” turned on “” I would recommend turning them off as you will always have trouble with xml if you don’t.
Thanks for reading the book!
=C=
Cal,
Thanks for the reply. Yes, turning off short tags was the trick to getting rid of the pesky messages when the XML was encountered. Now I’m having a problem on example two where I get a 404 error and it seems to be hitting /index/extract with the post data. I think that it may have to do something with my file structure. I currently am running XAMPP and have something like this:
C:\Users\charles\Documents\htdocs\app\
within htdocs I have the \lib\Zend directory and under \app I have all the MVC for my application. I’m wondering if my directory organization may be an issue? If so, this may help someone else out with the same snag. Can’t wait for it to work, though! I’ve tried every thing I can think of.
Thanks,
Charles
Cal,
Got example 2 to work and found that whatever directory structure I had mentioned above was causing the problem. I created a new directory, specifically for working examples out in the book and then pointed apache to the www as the web root. After that, it worked just fine following your directory structure. I’m sure it was a path issue that I wasn’t able to see or understand at this point. I’m fairly well versed in php, but am confident your book will help take me to the next level.
Thanks and all the best,
CharlesH
Hi CharlesH,
Sorry I’ve been AWOL, I’m glad you got it all sorted out.
=C=
About short tags. I like to keep them on. The tradeoff is to have to “echo” the first line of the xml document.
<?= ”; ?>
whoops I guess your input cleaner ate my xml declaration.
I’m looking at the printed book & the issue on page 22 is probably due to a copy & paste problem that originated on page 15 when the index.php bootstrap is being created.
You may want to include page 15 in your post so people can catch it in both spots.
I cannot get this first app to work. I’ve scrutinized my code, corrected the errata, and still I get:
Unexpected Exception: Invalid controller specified (index)
#0 /Volumes/data/scott/Sites/gpzf/library/Zend/Controller/Front.php(914): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /Volumes/data/scott/Sites/gpzf/html/index.php(25): Zend_Controller_Front->dispatch()
#2 {main}
Here’s my code:
$lib_paths = array();
$lib_paths[] = ‘/Volumes/data/scott/Sites/gpzf/application/’;
$lib_paths[] = ‘/Volumes/data/scott/Sites/gpzf/library/’;
$inc_path = implode(PATH_SEPARATOR, $lib_paths);
set_include_path($inc_path);
require_once ‘Zend/Loader.php’;
Zend_Loader::registerAutoload();
try {
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory(’/Volumes/data/scott/Sites/application/default/controllers/’);
$frontController->setParam(’noViewRenderer’, true);
$frontController->setParam(’noErrorHandler’, true);
$frontController->dispatch();
} catch (Exception $exp) {
$contentType = ‘text/html’;
header(”Content-Type: $contentType; charset=utf-8″);
echo ‘An unexpected error occurred:’;
echo ‘Unexpected Exception: ‘ . $exp->getMessage() . ”;
echo $exp->getTraceAsString();
echo ‘End of error message’;
}
I appreciate any help.
I’m using Zend Studio for Eclipse, Mac OS X 10.5.2 box, PHP 5.2.5
@Scott,
Greetz!
Did you download the source code from here on the website?
Also, what version of Zend Framework are you working with?
=C=
Hi Cal, thanks for the quick response. Yes, I tried using the downloaded source code, too (modified for my environment) as well as the downloaded Zend framework ‘as is’. My default ZF is 1.5.1. Thanks
Crap, I’m sorry. It was a typo in my $frontController->setControllerDirectory string. Sorry! Great book, thanks!!!
@CharlesH,
If you’re on a Mac, check out Skim. It’s a great PDF reader/annotator. You can copy in errata, highlight, strike out, etc…and it’s free.
@Scott (and all)
Ok, now that I’m back from my trip to Amsterdam, my goal is to test and fix all the sample code to work with 1.5. There may be issues with it. Let me take a look at it this weekend and I’ll post an update.
=C=
@Cal & @CharlesH
I’m hitting the same problems CharlesH has reported. So, thanks for posting!
I am stuck at the same point CharlesH reported on February 23rd, 2008 at 7:53 pm re: posting to /index/post.
Cal, could you please help? I am using Zend Studio for Eclipse and the default ZF directory structure it creates, I would like to understand why this (submitting the form) is not resolving properly, and how to fix it…vs. manually creating the directory structure and losing that feature of ZSE in future projects.
Many thanks!
btw, Amsterdam?? Wow…I need to go publish a book
@Scott,
I’ve not yet tried setting up a project in ZSE and the directory structure in the book was current as of the time of publication. (As with anything on the web, beyond that single day, it’s a crap shoot) :)
That having been said, all the pathing in the sample application is being handled in the bootstrap:
$lib_paths = array();
$lib_paths[] = “c:/web/htdocs/application”;
$lib_paths[] = “c:/web/htdocs/lib”;
and
$frontController->setControllerDirectory(’c:/web/htdocs/application/controllers/’);
(That’s from example2, it was the one I had handy)
So if your issue is in the path, you should be able to resolve it by adjusting one of those options.
Feel free to drop me an email at cal at calevans.com or if you see me on AIM:VirtualCIO if you are still having issues.
=C=
p.s. yep, Amsterdam but that was thanks to friends like IBuildings. :)
I’d suggest a specific front-page post about the short tags issue, since it seems to be On by default in a basic PHP/Apache installation. After not getting the chapter 2 code to run, I’d checked the errata posts but didn’t see anything, and so went back to looking for typos in my code. I only just now found the short tags issue here in the comments about an unrelated original post.
If it needs to feel like an actual “correction”, maybe say it should be added to the php.ini settings to check on page 6 (below the allow_url_fopen setting).
This is my first exposure to ZF, so I’m giving it a fresh eye ;)
Leave a Reply