0

我正在使用带有 log4php 和 smarty 的 zend 框架,在尝试运行 Zend 的引导程序时遇到了以下问题。

这是我得到的错误:

PHP Warning: require_once(Smarty.php): failed to open stream: 
No such file or directory in /var/www/html/kb/vaserver/VaDaemon/config.php on line 37 pid    
6049
Fatal error: require_once(): Failed opening required 'Smarty.php'

我认为我的问题与此处提到的以下问题非常相似,但是这个错误已经解决并修复了,我看到修复与詹姆斯在那里写的类似。无论如何,如您所见,这不起作用,所以我想知道我还应该尝试什么。

这是我的 config.php 代码:

/** *

date_default_timezone_set('Etc/UTC');

// The custom error handlers that ship with PHP Simple Daemon respect all PHP INI error settings.
ini_set('error_log', '/var/log/phpcli');
ini_set('display_errors', 0);

// Define a simple Auto Loader:
// Add the current application and the PHP Simple Daemon ./Core library to the existing include path
// Then set an __autoload function that uses Zend Framework naming conventions.
define("VA_BASE_PATH", dirname(__FILE__));              

set_include_path(implode(PATH_SEPARATOR, array(   
    realpath(VA_BASE_PATH . '/AbstractLayer/'), 
    realpath(VA_BASE_PATH), 
    realpath(VA_BASE_PATH . '/../'),
    realpath(VA_BASE_PATH . '/../Core'),
    get_include_path(),
)));

function vaDaemon_Autoloader($class_name)
{
    $class_name = str_replace('\\', '/', $class_name);
    $class_name = str_replace('_', '/', $class_name);
    require_once "$class_name.php"; // **line 37 as mentioned above in error** 
}

spl_autoload_register('vaDaemon_Autoloader');

function pathify($class_name) {
    return str_replace("_", "/", $class_name) . ".php";
}
4

1 回答 1

0

假设您使用 Composer 安装了 ZF2,如果您也安装 log4php 和 Smarty,它会让您的生活更轻松。更新您的composer.json并添加更新您现有的要求部分以将其他两个库添加到其中:

"require": {
    "apache/log4php": "2.3.0",
    "smarty/smarty": "3.1.19"
}

然后运行php composer.phar install。然后 composer 可以处理自动加载,您不需要对包含路径或spl_autoload_register().

于 2014-08-20T16:21:44.153 回答