views:

26

answers:

2

My application structure:

  • /application
    • /models
      • ShoppingCart.php
    • /modules
      • /orders
        • /models
          • Order.php

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()
 {
  #$this->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.

A: 

I think the class must be named:

class Application_Orders_Model_Order
ArneRie
A: 

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
takeshin
The first solution didnt work but once I added a Orders_Bootstrap (which zf create module DOES NOT create automatically) it worked. Thanks buddy I was totally hitting a wall on this one.
marko.vujo
@marko This is kind of the tricky one, you have to create it manually. I always forget about it too.
takeshin