I am a bit lost right now. I try to establish my own library but the autoloader seems not to be working somehow. This exaple here was the closest I found but all the solutions did not work for me.
This is my folder structure.
-application
|_modules
|_vita
|_controllers
|_IndexController.php
-data
-docs
-library
|_ND
||_Model
| |_Vita
| |_Vita.php
|_Zend
-public
-tests
This is my bootstrap.
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
...
protected function _initAutoloader()
{
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('ND_');
return $loader;
}
...
}
This is my complete application.ini (I am aware that the autoloaderNamespaces instruction is double with the one in the bootstrap but it does not work with both or each of them alone)
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
; automatic loading of libraries
autoloaderNamespaces[] = "ND_"
phpSettings.date.timezone = "Europe/Berlin"
;resources.frontController.controllerDirectory = APPLICATION_PATH "/modules/index/controllers"
;resources.frontController.params.displayExceptions = 0
;appnamespace = "Application"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.params.prefixDefaultModule = true
resources.frontController.defaultModule = "index"
resources.frontController.throwerrors = false
resources.frontController.params.displayExceptions = 0
; resources (modules)
resources.modules[] = ""
resources.view[] = ""
; resources (layout)
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = "main"
; db settings
resources.db.adapter = "PDO_MYSQL"
resources.db.isDefaultAdapter = true
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "nd"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
This is my Controller where I try to instantiate the class "Vita" But I always receive this Error: "Fatal error: Class 'ND_Model_Vita_Vita' not found in C:\xampp\htdocs\ND\application\modules\vita\controllers\IndexController.php on line 17"
class Vita_IndexController extends Zend_Controller_Action
{
public function init()
{
$this->view->headTitle('Vita');
}
public function indexAction()
{
/* Just to try if the Loader is working for the Zend library -> it works */
$this->newForm = new Zend_Form();
$this->mdlVita = new ND_Model_Vita_Vita();
Zend_Registry::get('log')->info($this->mdlVita->test());
}
}
And this is the Vita Class
class ND_Model_Vita_Vita
{
public function test()
{
return 'Is working';
}
}
Is there something I might have overlooked or I have to have in mind when using modules? I am thankful for any suggestion.
EDIT : I narrowd down the issue to have something to do with the xampp environment. I pushed the project to a live-apache location and there it worked.