Reputation: 4455
i am just started using zend framework. i created a project in zend
structure
application
configs
application.ini
layouts
modules
core
DB
Dbclass.php
Table
default
controllers
views
forms
bootstrap.php
library
public
index
my bootstrap file contain
public function _autoload(){
set_include_path(
'/application/modules/core/DB'
. PATH_SEPARATOR .
'/application/modules/core/Table'
. PATH_SEPARATOR .
get_include_path());
}
public function _init(){
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory(array(
'default' => APPLICATION_PATH.'/modules/default/controllers'
));
}
my application.ini file contain
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.timezone = "Europe/London"
;includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectory = APPLICATION_PATH "/modules/controllers"
resources.frontController.defaultModule = "default"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.params.displayExceptions = 0
when i create a object in indexcontroller
$new_object = new Dbclass();
there is an error showing that
Fatal error: Class 'Dbclass' not found in D:\xampp\htdocs\pubman\application\modules\default\controllers\IndexController.php on line 16
if any one know this please help me.
thanks in advance.
Upvotes: 0
Views: 94
Reputation: 14184
Several comments/observations:
You method Bootstrap::_autoload()
will not run. Bootstrap will automatically run all methods of the form _initXXX()
.
Typically, you would not put the models in modules/core/DB/*
. You would put them in modules/core/models/*
The default resource autoloader knows to look for them there.
You are specifying the appnamespace Application_
. That means that all the classes inside directories like application/models
, application/services
, application/forms
, etc would be named in the form Application_Model_Something
, not just Something
as you have. But since you have placed these classes inside the core module, they would be named something like Core_Model_Something
.
If you want to use modules, then you should have a resources.modules[] =
declaration in your application/configs/application.ini
You would typically have a Bootstrap class for each module - named, for exmaple, Core_Bootstrap
- extending Zend_Application_Module_Bootstrap
. This will ensure the standard resource autoloader for the module gets invoked.
This should get you closer. Frankly, there are a lot of things going on there, so this is unlikely to be a complete list. The essential part is to understand what the system would need to know in order to load a class that is not on the include_path
(like models, forms, etc): a namespace prefix, a base path at which it needs to start performing its PSR-0 construction.
Upvotes: 1