2013-10-18 44 views
0

對不起,我的英文,但請幫助我。我如何在模塊中找到模型。我使用Zend Framework 1.12,並在命令行中運行php文件。示例代碼:Zend Command Line無法在模塊中找到模型

//file located in project/scripts/test.php 
<?php 

//ini_set("display_errors","1"); ini_set("error_reporting", E_ALL); 
// Initialize the application path and autoloading 
defined('APPLICATION_PATH') 
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); 

defined('APPLICATION_ENV') 
    || define('APPLICATION_ENV', $argv[1]); 

set_include_path(implode(PATH_SEPARATOR, array(
    APPLICATION_PATH . '/../library', 
    get_include_path(), 
))); 

require_once 'Zend/Loader/Autoloader.php'; 

Zend_Loader_Autoloader::getInstance(); 

// Initialize Zend_Application 
$application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini' 
); 

//this model i can find 
$sendQueueModel = new Application_Model_DbTable_SendQueue(); 
//but this i can't. Managers - this is module in project 
$managersMOdel = new Managers_Model_Company(); 
+0

檢查這可以幫助你 - http://stackoverflow.com/questions/1836447/zend-modules-models/1837722#1837722 – janenz00

回答

0

該模塊不加載這就是爲什麼你不能訪問模型。通常情況下,我們在Bootstap.php中添加自動加載器,在這裏您應該嘗試使用相同的代碼來加載它。 (後初始化Zend_Application

$autoLoader = new Zend_Application_Module_Autoloader(array(
       'namespace' => 'Managers', 
       'basePath' => APPLICATION_PATH . '/modules/managers' 
      ));