Fatal error: Class 'Zend_Form' not found
I've started using Zend framework, and Im following this simple Zend form tutorial. The form is located in application/forms directory I have included the Zend framework in the Path (by going to comput开发者_如何学Cer properties). However when i access form.php page, i get this error:
Fatal error: Class 'Zend_Form' not found
I have also tried by copying the Zend folder from the Zend framework in the library folder of the application, however error still remains same. Thanks.
It sounds like you are confusing two notions: the system path and the include path.
The system path is an operating system concept. When you ask the OS to execute a command, the system path is a list of places to look for the executable.
In contrast, the include path is a PHP concept that tells PHP a list of folders in which to look for files invoked by PHP include/require
statements.
Any path that you find in "Computer > Properties" is almost certainly the OS-level system path. What you need to do is to make sure the Zend folder on the PHP include path, either by moving the Zend folder or by modifying PHP's include path to include a point to the Zend folder.
In a typical ZF app, the include folder is set in index.php
(the front controller). So, the only explanation for not finding Zend_Form is that the autoloader is not being instantiated.
If you are using Zend_Application
, this happens automatically. However, it seems like you are bypassing public/index.php
and the whole Zend_Application
instantiation by trying to directly "access" a file called form.php
directly. If this file contains only the definition of your form (extending Zend_Form
), then the absence of autoloading could easily explain the error message you are getting.
I'd try instantiating the form in a controller action, by which time in the request processing cycle, the autoloading is probably already in place.
[At that point, given the file locations you cite, we might run into a resource-loader issue, but that's a somewhat different issue that can be handled by instantiating a Zend_Application_Module_Autoloader
in your Bootstrap
.]
It looks like you do not use Zend_Loader
. You should focus on it.
You can also manually in your custom form class include Zend_Form
class.
精彩评论