I’m new to zend framework so maybe this question is stupid..
I’ve got a default hierarchy
site
|–bootstrap.php
|–application
|–models
|– Item.php
|– ModelAbstract.php
|–…
Inside Item.php there’s
<?php
//TODO: trying to remove this require...
require_once('ModelAbstract.php');
class CF_Model_Flower extends CF_Model_Abstract
{
...
Inside ‘ModelAbstract.php’ there’s
<?php
class CF_Model_Abstract
{
...
And my application Bootstrap.php looks like
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'CF',
'basePath' => dirname(__FILE__),
));
return $autoloader;
}
...
If I removed the ‘require_once’ inside Item.php I get
Fatal error: Class 'CF_Model_Abstract' not found in /Mysite/application/models/Item.php on line 6
Why ? And how can I use autoloading to live without this require_once ?
In fact, renaming ‘ModelAbstract.php’ to ‘Abstract.php’ works. Can someone explain me why ?
Thx
I’m not familiar with
Zend_Application_Module_Autoloaderand such. But if they work anything like earlier ZF autoloading mechanisms, the autoloader will look for class CF_Model_Abstract in:CF/Model/Abstract.phpor maybe with this namespace/basePath configuration in:
models/Model/Abstract.phpor:
models/CF/Model/Abstract.phpbut probably not in:
models/ModelAbstract.phpSo in other words, the underscores represent child directories.