Setting up the Zend Framework
by Naneau
This article is very old. I’m keeping it here for legacy reasons, but if you’re looking for help setting up Zend Framework, google is your friend.
I would like to take some time to talk about setting up the Zend Framework. It’s a lot easier than you might think. I know there are quite a few resources out there that deal with getting started, but some of them work with older versions of the framework, or are quite technical and hard to understand. I will try to keep things as easy as possible. There’s a Zend Framework sample file you can use. It uses the directory layout followed in this tutorial. The framework itself isn’t included, though.
To get started, you will need the framework itself. You can download it from Zend. And that’s pretty much all you need to download, because it doesn’t depend on anything. All you need for it to work is a working webserver, and php (any version above 5.1.4). You’ll have to decide where to put it. If you have your own local server, create a subdirectory for it in your web root. If you want to put it on a production server, you really shouldn’t need this tutorial
.
In the archive you have downloaded from Zend you will find a few directories under the root directory (the one called ZendFramework-[version]). The only one you really need is ‘library’. It contains the stable components of the framework. You may also want to extract the ‘incubator’ directory, it contains those components that aren’t yet ready for the library.
The question is, where to extract it to? You could put everything, framework and application, in a directory under your web root. If you have shared web hosting, or are just experimenting with the framework, this probably is the best choice for you. The disadvantage of this setup is that you must take some additional steps to make sure that you restrict access to those directories that contain your application and the framework. If you’ve downloaded my sample setup, you should put it under the library directory. Another option is to create a directory away from your webroot and put everything there, and have only the bootstrap file in the web root itself.
I’m going to follow the first option for this tutorial. Not because it’s better, but because it’s easier. I’m going to assume you put everything in a subdirectory of your web root called ‘zf’. Apart from the framework you will need models, views and controllers, and maybe configuration files. You should create subdirectories for them as well, ending up with a directory structure like this:
1 2 3 4 5 6 7 8 | /zf/ application/ /config/ /controllers/ /library/ /Zend/ /models/ /views/ |
That’s all you need to get started, file-wise. All you need now is a bootstrap file. Bootstrapping gets it’s name from Baron Münchhausen who claimed to have pulled himself out of a swamp by his own boot straps. For the Zend Framework this means you have to create a php file that loads the framework and starts the controller dispatch process, something it can’t do by itself.
The first thing you have to do in this bootstrap file is make sure the include path is set up correctly. You should at the very least include the directory in which you have put the framework, and the directory in which you will store your models. Also, be sure to set a default timezone. Call the file index.php and store it directly under the web root.
1 2 3 4 5 6 | set_include_path('.' . PATH_SEPARATOR . './application/library/' .PATH_SEPARATOR . './application/models/'); //include path to zend framework and models date_default_timezone_set('Europe/Amsterdam'); //timezone and time options //(I'm dutch, so for me it defaults to Europe/Amsterdam) |
Next, you can create an instance of Zend_Controller_Front, and start the dispatch process.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /** * Zend Front Controller */ require_once 'Zend/Controller/Front.php'; $controller = Zend_Controller_Front::getInstance(); //frontcontroller $controller->setControllerDirectory('./application/controllers/') //set the directory in which you put your controllers ->setBaseUrl('/zf') //subdirectory for requests //set this if you have installed the bootstrap in a subdirectory of your web root ->throwExceptions(true); //make it throw exceptions (handy for debugging) //don't do this on a production server $response = $controller->dispatch(); //do... something! |
You need just one little thing now. Your webserver should forward all requests to the bootstrap file. For apache you can do this using mod_rewrite with a .htaccess file. Be sure to include a RewriteBase if you have installed the framework in a subdirectory of the web root. Put it in the web directory.
1 2 3 | RewriteEngine on RewriteBase /zf/ RewriteRule !\.(js|css|ico|gif|jpg|png)$ index.php |
Remember that I said you should protect the application directory? Well, to do that you could put the following .htaccess file in there. It tells the web server to deny all direct requests to the directory.
1 | deny from all |
To get you started, I will provide you with a sample controller here. Put it under the controllers directory, in a file called IndexController.php. You can check if it works by browsing to http://yoursite.com/zf/ assuming you installed it in a ‘zf’ subdirectory. The dispatcher will check for an index controller by default, and call the index action on it, if no other controller and/or action is specified in the url.
1 2 3 4 5 6 7 8 9 10 | <?php require_once 'Zend/Controller/Action.php'; class IndexController extends Zend_Controller_Action { public function indexAction() { echo 'You now have the Zend Framework running! So, hello, world!)'; } } |
You should now have the following files and directories:
1 2 3 4 5 6 7 8 9 10 11 12 13 | /zf/ application/ .htaccess /config/ /controllers/ IndexController.php /library/ /Zend/ /models/ /views/ .htaccess index.php |
And that’s all there is to it! Of course, there are many more things you can do, especially in the bootstrap file. If you want to set up a database connection, you could do so in there. The same goes for the Zend Registry, a custom url router, and what have you. But this is more than enough to get you started! See my tutorial on the Zend Framework to give you some ideas about what to do with it.
Update
Andries Seutens has a great sample setup on his blog. It’s a good starting point for all users new to the framework.
Comments
Is there a way to test if you installed everything correct? I’m still a newb when it comes to the Zend Framework.
I ask this because I’m getting a 404 when I try to go to the index.php file… so I’m kinda wondering if I did anything wrong.
You added a function to the IndexController class… how and where do I have to caal it to see if it all works?
In fact, you don’t have to go to the index.php file at all. If you have installed it, put the .htaccess file in there, you just browse to wherever you put it, like http://yoursite.com/zf/ . The front controller automatically searches for an index controller then, and tries to call the indexAction.
I’ll try to put this into the tutorial. I realize now that it may not be that clear to newbies. Thank you. Maybe I’ll create a sample zip file with everything in it.
He can find the controller now, but I’m getting an error: http://pastebin.be/1569 (click link to see).
May it have something to do with the fact that I downloaded & installed the newest version of ZF (0.9.3), I noticed that it doesn’t come with the ‘Zend.php’ file as the previous versions.
And I would appreciate that zip-file with the entire structure of the app… I have never worked with the MVC-model, so I have a lot to learn.
Greetz,
Wouter
I have put up a zip file (see first paragraph of the tutorial). It includes everything from the tutorial. If you try copying that into your zf subdirectory and browse to http://yoururl/zf/ again, maybe I could help you better. Also, it might be helpful if I knew where you have installed it and what URL you use to browse to it.
The error you are seeing is a standard one that most people who experiment with the framework are quite familiar with. It means that the front controller can’t find a matching action controller for your request. Quite possibly you have set the wrong controller directory, or you have put the IndexController.php in the wrong directory.
I akready know what was wrong… I’m testing it locally, so I made a subfolder test and within I had the zf folder with everything. I adjusted the .htaccess file accordingly, but not the “->setBaseUrl” value.
So I got it working! Thnx for the help!
And I just want to say that your tuts are really helpfull and very easy to understand.
Bedankt!
Yes, it is important that you adjust the values (.htaccess and bootstrap) if you don’t put it in a ‘zf’ subdirectory. The front controller needs to know where it is in order to chop the URL into meaningful pieces.
I really try to make my tutorials easy to understand. I feel that a lot of the tutorials out there focus on getting as much code in as possible without explaining why they do things the way they do. It feels good to be appreciated
At any rate,
Graag gedaan!
Hi Naneau,
Thanks for this. Lots of tutorials with the basic ZF controller implemented. The real challenges I have with ZF is when integrating the views in place.
Harro
Hi,
Recently started exploring Zend framework. I had the framework running fine on my local machine, though I have a couple of questions when it comes to hosting environment
1) My webhost is running Php version above 5.1.4 but do i still to make sure if it has the Zend framework available.
2) My web host don’t support Apache server ….. is it necessary ?
3) I did set the include path for running the example on my local machine…nor sure but for the web hosting environment i believe we don’t need that …though what do we put in the include path in this case
Thanks in advance
Atiq
1) I don’t think your web host will provide the framework for you, and even if it did, you’d probably want your own version. You would have to upload it to your host along with the rest of the application. If your host is running 5.1.4+ it should work.
2) No, you can get it to work with other servers as well. I didn’t include it in this tutorial on purpose, because most people seem to be running apache. Have a look at: http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.introduction
3) You would make your include path refers to the place where your library is, and where your models are. That’s the bare minimum. It depends on where you put the files on your host.
If I have a web-application containing multiple modules, how should I setup the directory structure?
For example:
I have
http://localhost/blog/archive/list/sort/alpha
and
http://localhost/forum/profile/show/user/some_user
The two modules are: blog and forum
How should I setup the directories with its controllers and models?
Yes, you should create different directories for your modules, within the application directory. In each module directory, you could put subdirectories for it’s models, views and controllers.
I cant understand how to implement conventional modular layout, all tutorials use conventional layout. Do you know some tutorial that implements the modular layout.
thanks.
I’ll see if I can write up a little tutorial on modules later on. It seems to be a recurring question
I thought that I did everything step by step correctly, but I always gets this:
Serverfehler!
Die Anfrage kann nicht beantwortet werden, da im Server ein interner Fehler aufgetreten ist. Der Server ist entweder überlastet oder ein Fehler in einem CGI-Skript ist aufgetreten.
Sofern Sie dies für eine Fehlfunktion des Servers halten, informieren Sie bitte den Webmaster hierüber.
Error 500
localhost
06/06/07 23:55:25
Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.2
Maybe you could gave me some advises what I did wrong…
so thanks
My German isn’t what it used to be, but judging from what you are seeing my guess is that there is some kind of problem with your .htaccess file. Check whether you set up the subdirectory in it.
i have the next error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost 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.
i dont know why.
Hi!
First, i give you the congratulations about your tutorial. Help me a lot
I’m thinking put zend framework connecting with google calendar, but after the install, i has the same problem that Carlos cruz
“The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost 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.”
I used the zip file like you put on your web site
Hi Naneau,
thanks for tutorial.
I did all step by step and get following error:
Fatal error: Uncaught exception ‘Zend_View_Exception’ with message ’script ‘index/index.phtml’ not found in path (.applicationviewsscripts)’ in C:wwwblogapplicationlibraryZendViewAbstract.php:856 Stack trace: #0 C:wwwblogapplicationlibraryZendViewAbstract.php(764): Zend_View_Abstract->_script(‘index/index.pht…’) #1 C:wwwblogapplicationlibraryZendControllerActionHelperViewRenderer.php(732): Zend_View_Abstract->render(‘index/index.pht…’) #2 C:wwwblogapplicationlibraryZendControllerActionHelperViewRenderer.php(753): Zend_Controller_Action_Helper_ViewRenderer->renderScript(‘index/index.pht…’, NULL) #3 C:wwwblogapplicationlibraryZendControllerActionHelperViewRenderer.php(800): Zend_Controller_Action_Helper_ViewRenderer->render() #4 C:wwwblogapplicationlibraryZendControllerActionHelperBroker.php(160): Zend_Controller_Action_Helper_ViewRenderer->postDispatch() #5 C:wwwblogapplicationlibraryZendControllerAction.php(504): Zend_Controller_Action_HelperBroker->notifyP in C:wwwblogapplicationlibraryZendViewAbstract.php on line 856
What is wrong ?
ZendFramework RC3
Heh i fount the solutions,
Before dispath you need to add the following line:
$controller->setParam(‘noViewRenderer’, true);
Thank You anyway!
Hi i am trying your tutorial locally and i made the folder named zf and made the architecure accordingly as you described when i open http://tequila/gauravcvs/zf it automatically calls the default action and default controller , but when i calls defined action let’s say add as http://tequila/gauravcvs/zf/index/add
i got the message page not found even when i call http://tequila/gauravcvs/zf/index it also gives the page not found error i am in trouble plz help me out.
with regards
Gaurav
You probably have the .htaccess set up wrong. Or, it’s possible that your apache setup doesn’t allow overrides (so it will not look at the .htaccess at all). XAMPP for instance sets AllowOverride to none in it’s configuration files. A quick google should help you to get on your way with this
hi i am using Apache/2.2.0 (Fedora) in my httpd.conf file i have enabled the mod_rewrite module and for the AllowOverride none statement i have changed it to All instead of none and following is my .htaccess code
RewriteEngine on
RewriteBase /gauravcvs/zf
RewriteRule !.(js|css|ico|gif|jpg|png)$ index.php
and if you require any other info then plz let me know and direct me for a gud solution i am really hanging with this problem from last 4 days.
with regards
Gaurav Mudgil
What your probably need to do is:
$frontController->setBaseUrl(‘/gauravcvs/zf’);
where $frontController is the front controller in your bootstrap. Let me know if that works, if it doesn’t, why not join #zftalk on irc.freenode.net (see http://www.zftalk.com for a java applett that will get you online). There are plenty of people there willing to help you
Hi
I am already using setBaseUrl in my bootstrap file
require_once ‘Zend/Controller/Front.php’;
require_once ‘Zend/Controller/Router/Route.php’;
$_SERVER['PHP_SELF'] = substr($_SERVER['PHP_SELF'], 0, strlen($_SERVER['PHP_SELF']) – @strlen($_SERVER['PATH_INFO']));
$baseUrl = substr($_SERVER['PHP_SELF'], 0, -9); //
// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setBaseUrl($baseUrl);
$frontController->setControllerDirectory(‘./application/controllers’);
$frontController->dispatch();
this is the code in my bootstrap file
and i registered at http://www.zftalk.com but let me know which link of section of the site provides online talk .
can you please send my ur structure and code . really Friend i am getting tensed because i am hanging with zend from last week with no solution.
So plz help
bye
tc
The url for the java applet is: http://www.zftalk.com/irc.php
Also, the base url should be the subdirectory in which you plant your installation. Which, in your case, is ‘/gauravcvs/zf’, I gather that you’re trying to automatically detect it, but you may be better of just setting it by hand. I can’t really see what’s the problem at this point, but I can only guess it has something to do with the base url. Please try to join #zftalk, I hope to be able to better help you there.
my automaic base url returns ‘/gauravs/zf/’ but when i add manually ‘/gauravs/zf’ as you specified
and i open http://tequila/gauravs/zf i got the error as invalid controller (‘zf’) specified
So please let me know what to do further
or give me ur id i wil send you my whole folder
With Regards
Gaurav Mudgil
am not getting what exactly is explained in this tutorial.
Can you just brief it .
it explains a little about the directory structure you can use for setting up the framework. If you want a complete getting-started-guide I would suggest akrabat’s tutorial: http://akrabat.com/zend-framework-tutorial/
i follow u step by step, and i get this error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@localhost.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.
this is my .htaccess
RewriteEngine on
RewriteBase /zend/
RewriteRule !.(js|css|ico|gif|jpg|png)$ index.php
plz help
Dear Naneau ,
I have been trying to setup a zend framework. I followed your guidelines and tried to setup the framework using the sample file you had provided. However, i have encountered this error time and time again.
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/19/07 08:37:59
Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8d mod_autoindex_color PHP/5.2.1
What am i doing wrong to produce this error.Am i to change anything in my php.ini? And if i have to make some alteration How do i do it?
Lastly, what do i do to rectify the error?…please help
If you are getting the Internal Server Error message, make sure you have mod_rewrite enabled in your apache config – that fixed the problem for me.
Uff… these were really hard three hours, but get it working under my directory layout and with nusphere debugger. I believe that it would take 3 days without a basic tutorial like this one.
Thanks a lot.
Hi Naneau,
After I added this line
$controller->setParam(’noViewRenderer’, true);
everything works fine.
Thnx for the tutorial, it helps me!
that line will disable the viewRenderer. If you don’t want it, it’s fine, but please note that it’s a standard part of the framework’s MVC components nowadays, that’s why you have to disable it explicitly (instead of enabling it if you want to use it)
[...] Maurice Fonk’s article ‘Setting Up the Framework’ [...]
i used your method now i am getting this :-Fatal error: Uncaught exception ‘Zend_View_Exception’ with message ’script ‘index/index.phtml’ not found in path (.applicationviewsscripts)’ in C:xampphtdocszfapplicationlibraryZendViewAbstract.php:856 Stack trace: #0 C:xampphtdocszfapplicationlibraryZendViewAbstract.php(764): Zend_View_Abstract->_script(‘index/index.pht…’) #1 C:xampphtdocszfapplicationlibraryZendControllerActionHelperViewRenderer.php(742): Zend_View_Abstract->render(‘index/index.pht…’) #2 C:xampphtdocszfapplicationlibraryZendControllerActionHelperViewRenderer.php(763): Zend_Controller_Action_Helper_ViewRenderer->renderScript(‘index/index.pht…’, NULL) #3 C:xampphtdocszfapplicationlibraryZendControllerActionHelperViewRenderer.php(810): Zend_Controller_Action_Helper_ViewRenderer->render() #4 C:xampphtdocszfapplicationlibraryZendControllerActionHelperBroker.php(160): Zend_Controller_Action_Helper_ViewRenderer->postDispatch() #5 C:xampphtdocszfapplicationlibraryZendControllerAction.php(5 in C:xampphtdocszfapplicationlibraryZendViewAbstract.php on line 856
please tell me whats wrong?
the problem you are describing comes from the view renderer. Read more about it in the Frequently Encountered Problems list on Zends Wiki: http://framework.zend.com/wiki/display/ZFUSER/Frequently+Encountered+Problems
hi Naneau,
i just read about an example at YouTube.com and was going to try it. it uses the Zend Framework which i needed to install at my shared hosting company. my question is, since it is written in php5 and with the hosting company running php4 and php5, whereas files with the extension “php5″ will be treated as such, and files with the extension “php” will be treated as php4 files, i was wondering if i must rename all the files to php5? :-{
on my initial installation (which i removed again since i’m now not sure about the file extensions), i got the similar error message as rstechnocrats.
thanks for your fine efforts.
johannes
Johannes, isn’t there a way to make your whole system run php5? Maybe you can set it up in your .htaccess config, or on a per-directory basis. Changing all file extensions sounds like a nightmare in maintenance…
hi Naneau,
i had a problem with the installation yesterday, i think the session expired during the ftp upload, so i did it all over again and was finished at 4 this morning. i also read in my providers help files about the .htaccess and entered additional code in the .htaccess file, but i didn’t dare to test it yet, also due to a time problem, 10 hours on the job today. i’ll post here more info if i figured that it worked. … i just tried to retrieve the file, here’s the error message:
Uncaught exception ‘Zend_View_Exception’ with message ’script ‘index/index.phtml’ not found in path (./application/views/scripts/)’ in
don’t know why it suddenly wants phtml, i never put that into the .htaccess file. … more work to be done.
johannes
You should really have a look at the viewRenderer introduction, it explains why it complains about .phtml files. It’s a new addition to the framework that takes some getting used to
http://devzone.zend.com/article/2072-Zend-Frameworks-MVC-Introduces-the-ViewRenderer
hi,
i’m very newbie in php world
i have download your sample but i still get some error in the server
here are some errors :
[Fri Feb 08 09:41:31 2008] [alert] [client 127.0.0.1] C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/zf/.htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration
[Fri Feb 08 09:41:31 2008] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Fri Feb 08 09:41:41 2008] [alert] [client 127.0.0.1] C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/zf/.htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration
hi after trouble shoot by my self
here the latest error when i hit http://localhost:8080/zf
[Fri Feb 08 13:51:50 2008] [error] [client 127.0.0.1] PHP Fatal error: Uncaught exception ‘Zend_View_Exception’ with message ’script ‘index/index.phtml’ not found in path (.\application\views\scripts\)’ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\View\Abstract.php:857nStack trace:n#0 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\View\Abstract.php(765): Zend_View_Abstract->_script(‘index/index.pht…’)n#1 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\Controller\Action\Helper\ViewRenderer.php(742): Zend_View_Abstract->render(‘index/index.pht…’)n#2 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\Controller\Action\Helper\ViewRenderer.php(763): Zend_Controller_Action_Helper_ViewRenderer->renderScript(‘index/index.pht…’, NULL)n#3 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\Controller\Action\Helper\ViewRenderer.php(811): Zend_Controller_Action_Helper_ViewRenderer->r in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\View\Abstract.php on line 857
then here is when i hit http://localhost:8080/zf/index.php :
[Fri Feb 08 13:52:45 2008] [error] [client 127.0.0.1] PHP Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (index.php)’ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\Controller\Dispatcher\Standard.php:194nStack trace:n#0 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\Controller\Front.php(920): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))n#1 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\index.php(25): Zend_Controller_Front->dispatch()n#2 {main}n thrown in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zf\application\library\Zend\Controller\Dispatcher\Standard.php on line 194
can you help me? did i miss some configuration?
It’s great that you went and did all this work. I finally got this working on WAMP, and will soon start using this concept on live servers.
A couple of errors that I have battled through, (so, I can help a little bit here.).
Hiro Nakamura.
for your issue, you do not have mod_rewrite turned on in your apache setup.
to do so, search for “rewrite_module” in your appache’s httpd.conf file and uncomment the line (just take the # mark away from it. If it doesn’t exist in there simply add a line that says.
LoadModule rewrite_module modules/mod_rewrite.so
For those of you who may be getting a 500 internal server error, your problem is that you need to put the zf folder in your root directory, and NOT make zf your root directory.
Of course, if you want to make zf your root directory, perhaps deleting the “rewriteBase /zf/” line from the .htaccess file will do the trick.
you will also need to comment out line 18 of the index.php (bootstrap) provided
->setBaseUrl(‘/zf’)
IF YOU HAVE A NEWER VERSION OF ZEND::
you run into all kinds of issues with the error regarding PHTML files. If you are working with the provided bootstrap here, you need to add a line, making your last three lines look like
$controller->setParam(‘noViewRenderer’, true);
$response = $controller->dispatch();
//do… something!
This should get you set up.
Mike
[...] Naneau » Setting up the Zend Framework – I find this guy’s tutorials very informative and useful [...]
Very helpful tutorial. Thanks.
wow
its very interesting point of view.
Nice post.
realy good post
thx
This is an excellent tutorial which has really helped; however, i am currently using ZF v1.6 and just cannot seem to get past the error:
zend framework Uncaught exception ‘Zend_View_Exception’ with message ’script ‘index/index.phtml’ not found
Which you can see at: http://www.stanstedessex.com/zf/
Any ideas or possible help to getting this sample working? Is it a ZF v1.6 issue – or am I doing somthing wrong?? I have looked at the solution given by Yaroslav Vorozhko but it does not help!?
Thanks in advance, and of course for the tutorial..
you are missing the relevant view scripts for an action. Have a look at the action helper documentation for “ViewRenderer”, which has details on how to set it up (or turn it off)
How could I add favicon in my site using zend framework? IE only support favicon.ico from root folder while zend is not execute any file except index.php from the root.
I have tried to put favicon.ico files in image folder and it works in FF but not worked in IE.
baseUrl}/images/favicon.ico” type=”image/x-icon” />
Would appreciate your help.
Thanks,
Hello,
in my .htaccess I saved the following line:
RewriteRule !.(js|ico|gif|jpg|png|css|exe|pdf)$ index.php [L]
But when I will link to an exe-file in, I will get en error message:
Link: baseUrl();?>/_files/test.exe” target=”_blank”>…
What is wrong there?
Thanks.
i m having one problem. when i run the applcation on my system it runs smoothly. but the same application when i run on server, it opens the homepage but further more pages are not accessed but the error is:
Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (searchresult)’ in /nfs/c03/h02/mnt/50762/domains/waynii.com/html/library/Zend/Controller/Dispatcher/Standard.php:241 Stack trace: #0 /nfs/c03/h02/mnt/50762/domains/waynii.com/html/library/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /nfs/c03/h02/mnt/50762/domains/waynii.com/html/directory/index.php(34): Zend_Controller_Front->dispatch() #2 {main} thrown in /nfs/c03/h02/mnt/50762/domains/waynii.com/html/library/Zend/Controller/Dispatcher/Standard.php on line 241
please help me.
I keep having this error whenever I try running the starters tutorials on Zend.
Notice: Undefined index: default in C:wampwwwzflibraryZendControllerDispatcherStandard.php on line 432
Strict Standards: Implicit cloning object of class ‘Zend_Controller_Request_Http’ because of ‘zend.ze1_compatibility_mode’ in C:wampwwwzflibraryZendControllerRequestAbstract.php on line 100
Warning: Zend_Controller_Dispatcher_Standard::include_once(IndexController.php) [function.Zend-Controller-Dispatcher-Standard-include-once]: failed to open stream: No such file or directory in C:wampwwwzflibraryZendControllerDispatcherStandard.php on line 334
Warning: Zend_Controller_Dispatcher_Standard::include_once() [function.include]: Failed opening ‘IndexController.php’ for inclusion (include_path=’.;../library/;../application/models;.;C:php5pear’) in C:wampwwwzflibraryZendControllerDispatcherStandard.php on line 334
Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Cannot load controller class “IndexController” from file “IndexController.php” in C:wampwwwzflibraryZendControllerDispatcherStandard.php:336 Stack trace: #0 C:wampwwwzflibraryZendControllerDispatcherStandard.php(255): Zend_Controller_Dispatcher_Standard->loadClass(‘IndexController’) #1 C:wampwwwzflibraryZendControllerFront.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #2 C:wampwwwzfpublicindex.php(16): Zend_Controller_Front->dispatch() #3 {main} thrown in C:wampwwwzflibraryZendControllerDispatcherStandard.php on line 336
Hey there,
I am new to zend and am just trying to get started. I have uploaded the files from the zip onto my web directory and have added the zend files into the lib directory. I havent changed the code and just wanted to see what it would do without me changing anything yet. The problem I am having is that I get this error code and I don’t know what I have done so that it doesn’t understand the code.
The error is a common one, but I don’t know why it is happening:
unexpected T_OBJECT_OPERATOR on line 18
line 18: ->setBaseUrl(‘/zf’)
Yaroslav Vorozhko was right. You have to include
$controller->setParam(‘noViewRenderer’, true);
in the bootstrap file, if not, Zend will search for a view to render and it will trown a view exception.
dude, this is real
That really helped! I could not find something something similar in ZF site in beginner docs… CI and Kohana had that bootstrap and dir structure by default…. thanks!
HI
I follow the step but gettng the following error, plz help me out
Fatal error: Uncaught exception ‘Zend_View_Exception’ with message ’script ‘index/index.phtml’ not found in path (.\application\views\scripts\)’ in F:\wamp\www\zf\application\library\Zend\View\Abstract.php:924 Stack trace:
#0 F:\wamp\www\zf\application\library\Zend\View\Abstract.php(827): Zend_View_Abstract->_script(‘index/index.pht…’)
#1 F:\wamp\www\zf\application\library\Zend\Controller\Action\Helper\ViewRenderer.php(903): Zend_View_Abstract->render(‘index/index.pht…’)
#2 F:\wamp\www\zf\application\library\Zend\Controller\Action\Helper\ViewRenderer.php(924): Zend_Controller_Action_Helper_ViewRenderer->renderScript(‘index/index.pht…’, NULL)
#3 F:\wamp\www\zf\application\library\Zend\Controller\Action\Helper\ViewRenderer.php(963): Zend_Controller_Action_Helper_ViewRenderer->render()
#4 F:\wamp\www\zf\application\library\Zend\Controller\Action\HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#5 F:\wamp\www\zf\application\library\Zend\Controller\Action.php(523): Zend_Controller_Action_ in F:\wamp\www\zf\application\library\Zend\View\Abstract.php on line 924
accessible blew overseeing ripping colorado signs expansive exploit aberdeen refrigerator fowlers
lolikneri havaqatsu
Bravo, what necessary phrase…, a remarkable idea Oh, good joke) Why did the cannibal rush over to the cafeteria? He heard children were half price. 1]vigera canada
For the last 3 days i am trying to set up Zend Framework in lot s of different ways. Now I think I finally find how to do that. But I have these questions:
1. I am using Xampp , with localhost, can this procedure be used with it or I need something else.
2. As I noticed the red text in the files should be changed, but I am making errors every rime I change something. How should my set_include_pathlook like, considering the fact that I have copied the zf directory in c:/xampp/htdocs in order with subfolders like you have showed
3. How should I change this lines for my use:
- require_once ‘Zend/Controller/Front.php’
- $controller->setControllerDirectory(‘./application/controllers/’)
- ->setBaseUrl(‘/zf’)
4. Should I write something after or before: $response = $controller->dispatch();
5. in my .htaccess file I have the three lines you have show, shoul I add something
6. I have only the controller you have described, should I make changes there, and do I need to make model and view.
7. Should I add, and where these lines:
$controller->setParam(‘noViewRenderer’, true);
And $frontController->setBaseUrl(‘/zf’);
I have to mention that .htaccess and bootstrap are in zf file, like shown.
I am new in zend and i hope to get answers for almost all my questions, because I cant handle another 3 days torturing with zend set up.
Thanks
In my site ..i have got an error…
Fatal error: Uncaught exception ‘Zend_View_Exception’ with message ’script ’storefront.phtml’ not found in path (C:\wamp\www\zend-demo\application/layouts/;C:/wamp/www/zend-demo/application/views\scripts/;./views\scripts/)’ in C:\wamp\www\zend-demo\library\Zend\View\Abstract.php:976 Stack trace: #0 C:\wamp\www\zend-demo\library\Zend\View\Abstract.php(876): Zend_View_Abstract->_script(’storefront.phtm…’) #1 C:\wamp\www\zend-demo\library\Zend\Layout.php(796): Zend_View_Abstract->render(’storefront.phtm…’) #2 C:\wamp\www\zend-demo\library\Zend\Layout\Controller\Plugin\Layout.php(143): Zend_Layout->render() #3 C:\wamp\www\zend-demo\library\Zend\Controller\Plugin\Broker.php(331): Zend_Layout_Controller_Plugin_Layout->postDispatch(Object(Zend_Controller_Request_Http)) #4 C:\wamp\www\zend-demo\library\Zend\Controller\Front.php(965): Zend_Controller_Plugin_Broker->postDispatch(Object(Zend_Controller_Request_Http)) #5 C:\wamp\www\zend-demo\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch() in C:\wamp\www\zend-demo\library\Zend\View\Abstract.php on line 976
pls give me the solution …
Hello Sir,
I tried to run a sample application but got the following error only.. One of my friend told me to configure zend+wamp to solve this issue.. But I don’t know how to configure them..
The error is..
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@localhost 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.
Need your help..
Thanks in advance..