简体   繁体   中英

Couldnt load Zend/Application.php when move project from win7 to Ubuntu

I have a project running in win7 (with xampp installed - zend framework 1.10.3). But when I moved it to Ubuntu, I had a problem. My project structure is :

Myproject
    application
    library
        Zend
    include
        application.ini
    etc...
    index.php

Here is my index.php:

<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

define('APP_ROOT', realpath(dirname(dirname(__FILE__))));

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

require_once 'include/constant.inc.php';
require_once('include/class.phpmailer.php');

// set constant in Zend_Registry
//require_once 'Zend/Registry.php';
//Zend_Registry::set('const', $cfg);

/** Zend_Application */
require_once 'Zend/Application.php';

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

And here is my include/application.ini:

[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
phpSettings.date.timezone = "Europe/London"
;includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = ""

;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
;resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""

autoloaderNamespaces.Zendex = "Zendex_"


resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = 
resources.db.params.dbname = qtcms
resources.db.params.charset = "utf8"


resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view[] =
;resources.layout.layout = "layout"
admin.resources.layout.layout = "admin"
resources.view.doctype = "XHTML1_STRICT"
resources.view.helperPath    = APPLICATION_PATH "/helpers/views/"
resources.view.helperPathPrefix = "Zend_View_Helper_"
;resources.view.params.default.basePath                            = APPLICATION_PATH "/layouts/default/"
;resources.view.params.default.layout                              = "layout"
;resources.view.params.default.layoutPath                          = APPLICATION_PATH "/layouts/default/default/"

;resources.view.params.admin.basePath                            = APPLICATION_PATH "/layouts/admin/"
;resources.view.params.admin.layout                              = "layout"
;resources.view.params.admin.layoutPath                          = APPLICATION_PATH "/layouts/admin/default/"



[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

With these configurations, I have no problem on having my project run on windows (with xampp was installed).

In ubuntu, i had xampp installed following this guide:

http://humanlanguage.wordpress.com/2006/12/03/install-xampp-on-ubuntu/

According to that guidance, I've created a symlink (if i didnt wrong) to linking my /home/truong/webdev folder with /opt/lampp/htdocs folder.(with "truong" is my name ^_^) Then i moved my project to /home/truong/webdev. After that, I run my project from browser ULR : localhost/webdev/myProject and i had this error:

Warning: require_once(Zend/Application.php) [function.require-once]: failed to open stream: No such file or directory in /home/truong/webdev/qtcms/index.php on line 28

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Application.php' (include_path=':.:/opt/lampp/lib/php') in /home/truong/webdev/qtcms/index.php on line 28

It looks like that the system couldn't find my library/Zend folder.

I wondered that should i set the include path for my Zend library in php.ini manually, but then I thought it wasnt neccessary, cause I had it set in index.php

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

I've searched many times on the Internet but nothing found helpful. Please help me solving this problem... Thanks so much. ps: my appologize for my bad English. quangtruong1985

Posts: 1 Joined: Thu Jan 06, 2011 4:24 pm

It seems like your library path isn't actually added to your include path. you may want to check this via print_r(get_include_path());

I had some problems with realpath in the past, so maybe this is causing your problem. You could try

set_include_path(implode(PATH_SEPERATOR, array(
    dirname(__FILE__) . '/library',
    get_include_path(),
)));

to avoid realpath

It looks like you commented out the include directive in your application.ini. It is this one: ;includePaths.library = APPLICATION_PATH "/../library" . If you remove the ';' at the beginning of the line it should work out.

On your Windows machine did you add the path to the Zend Framework to the php.ini? If so that´s probably the reason why it won´t work on Linux.

You also have to consider the following: if you have an installation of XAMPP on your windows machine, PEAR is installed by default and the zend framework comes with it.

EDIT: Some grammar.

Can you check whether the include path for the library in php.ini file is commented,

;include_path = ".;c:\\php\\includes;d:..\\zendframework\\library"

if commented, please remove the the semicolon and restart the server.

My php.ini directive was like this

include_path = ".;C:\\xampp\\php\\PEAR;C:\\zend\\zendframework1116;C:\\zend\\zendframework1116\\library;"

removing ; at the end of path solved my problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM