将index.php移出应用程序根目录在zend框架中工作

问题描述:

我正在尝试更改index.php的路径。将index.php移出应用程序根目录在zend框架中工作

我有一个引导带zend结构。

所以我创建了一个名为newapp的新文件夹,它的路径是我们的index.php所在的根路径。

然后我将index.php复制到newapp,以便我可以从newapp目录加载应用程序。

但问题是我无法从我复制的index.php中加载配置文件。它thorws错误,下面给出。

Fatal error: Uncaught exception 'Zend_Config_Exception' with message 

'parse_ini_file(E:\xampp\htdocs\..../configs/application.ini) [<a href='function.parse- 

ini-file'>function.parse-ini-file</a>]: failed to open stream: No such file or directory' 

in E:\xampp\htdocs\ZendFramework-1.12.0\library\Zend\Config\Ini.php:182 

注意我的文件夹结构

- trunk 

     - index.php 
     - application 
      - bootstrap.php 
      - configs 
       - config.ini 
     - newapp 
      - index.php (copy of above) 

我实际的index.php如下

<?php 
    ini_set('memory_limit', '-1'); 
    set_time_limit(0); 
    defined('BASE_PATH')|| define('BASE_PATH', realpath(dirname(__FILE__))); 
    define('APPLICATION_PATH', BASE_PATH . '/application'); 

    set_include_path('../../library1.12.0/'. get_include_path()); 

    require_once 'Zend/Loader/Autoloader.php'; 
    $loader = Zend_Loader_Autoloader::getInstance(); 
    $loader->setFallbackAutoloader(true); 

    defined('APPLICATION_ENV')|| define('APPLICATION_ENV',(getenv 

('APPLICATION_ENV') ? getenv('APPLICATION_ENV'): 'staging_mysql')); 


    $application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini' 
    ); 
    $application->bootstrap(); 
    $application->run(); 

鉴于我应该改变的index.php?

  • 我试图更改配置文件的路径为

    APPLICATION_PATH。 “/../../configs/application.ini”

,但没有工作 - Zend库可怎么一回事,因为我从窗户

enviornment变量设置中设置PATH变量以它。

  • 我想这也realpath(dirname(__FILE__))."/.."

不过,这不加载应用程序。

尝试添加

set_include_path(
    APPLICATION_PATH.'/../library1.12.0'.PATH_SEPARATOR. 
     APPLICATION_PATH.'/../library1.12.0/Zend' 
); 
+0

我试过但:警告:require_once(Zend/Loader/Autoloader.php)[function.require-once]:无法打开流: –

defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__))); 
define('APPLICATION_PATH', BASE_PATH . '/application'); 
set_include_path('../../library1.12.0/'. get_include_path()); 

应该是这NEWAPP/index.php文件与线下方

defined('BASE_PATH')|| define('BASE_PATH', realpath(dirname(__FILE__))); 
defined('APPLICATION_PATH') 
    || define('APPLICATION_PATH', BASE_PATH . '/../../application'); 

// Ensure library/ is on include_path 
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library1.12.0'), 
    get_include_path() 
))); 

注: 文件夹 'library1.12.0' shoould在应用程序文件夹级别和Zend文件夹应该在里面。希望这会帮助你,我已经测试过它和它的工作。