My application structure:
- /application
- /models
- ShoppingCart.php
- /modules
- /orders
- /models
- Order.php
- /models
- /orders
- /models
I want to create a module application so in my application.ini I put:
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
Basically my Application_Model_ShoppingCart for my main application needs the Orders_Model_Order to place an order:
class Application_Model_ShoppingCart
{
static public $mCartId;
function __construct()
{
#$th开发者_如何学运维is->OrderModel = new Orders_Model_Order();
$this->SetCartId();
}
}
class Orders_Model_Order
{
function __construct()
{
$this->PP_Session = Zend_Registry::get('PP_Session');
}
}
But I keep getting a fatal error:
Fatal error: Class 'Orders_Model_Order' not found in .. /application/models/ShoppingCart.php on line 13
I keep trying different things but it still doesnt include this module with the autoloader. Is there something I should be doing?
Thanks in advance.
Two possible solutions.
Add in application.ini
:
autoloaderNamespaces[] = 'Application_'
or add module bootstrap:
// /application/modules/orders/Boostrap.php
class Orders_Bootstrap extends Zend_Application_Module_Bootstrap {}
and put your Order_Model_Order
models to:
/application/modules/orders/models/Order.php
I think the class must be named:
class Application_Orders_Model_Order
精彩评论