davidsperling
asked on
Zend Framework - Zend_Loader_Autoloader doesen't work for me
Can't seem to get autoload working.
See screenshots!
error.png
See screenshots!
*** Bootstrap.php ***
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDoctype()
{
$this->bootstrap('view');
$view = $this->getResource('view');
$view->doctype('XHTML1_STRICT');
}
protected function _initAutoloader()
{
$loader=Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
}
}
*** TestController.php ***
<?php
class TestController extends Zend_Controller_Action
{
public function indexAction()
{
$b=get_include_path(); //debug - yes
$a=new mylittlekalle("littlekalle");
}
}
*** kallbanan.php ***
<?php
class mylittlekalle extends Zend_Form_Element_Select
{
public function kalle()
{
return "kalle";
}
}
*** index.php ***
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
// Ensure /application is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH ),
get_include_path(),
)));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
dirs.pngerror.png
ASKER
"$loader->setFallbackAutol oader(true )" means that you don't have to register namespaces, doesn't it?
I've also tried with namespaces, but it still doesn't work. Have no idea why.
I've also tried with namespaces, but it still doesn't work. Have no idea why.
ASKER
... and since /application is in inlude path, classes in /application/kalle should be detected automatically, shouldn't them?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have absolutely no luck at all!
Let's put it this way...
Can you modify the ZF Quick Start project so that Zend_Loader_Autoloader is used on a custom folder named myclasses (residing in application path) with namespace Mynamespace_?
http://framework.zend.com/demos/ZendFrameworkQuickstart.zip
http://framework.zend.com/demos/ZendFrameworkQuickstart.tar.gz
I don't want to mess around with a lot of "require_once"... That's not why I use ZF!
Let's put it this way...
Can you modify the ZF Quick Start project so that Zend_Loader_Autoloader is used on a custom folder named myclasses (residing in application path) with namespace Mynamespace_?
http://framework.zend.com/demos/ZendFrameworkQuickstart.zip
http://framework.zend.com/demos/ZendFrameworkQuickstart.tar.gz
I don't want to mess around with a lot of "require_once"... That's not why I use ZF!
ASKER
ASKER
..
ee2.png
ee2.png
Open in new window