[英]Unclear error while trying to connect to Zend with smarty and apache log4php
我在zend框架中使用log4php和smarty,在嘗試運行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'
我認為我的問題與此處提到的問題非常相似,但是此錯誤已解決並修復,我看到的修復與James在此處編寫的類似。 無論如何,這都不起作用,如您所見,所以我想知道還應該嘗試什么。
這是我的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";
}
假設您使用Composer安裝了ZF2,那么同時安裝log4php和Smarty也可以使您的生活更輕松。 更新您的composer.json
並添加更新現有的require部分,以向其中添加其他兩個庫:
"require": {
"apache/log4php": "2.3.0",
"smarty/smarty": "3.1.19"
}
然后運行php composer.phar install
。 然后composer可以處理自動加載,而您不需要使用include路徑或spl_autoload_register()
進行任何操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.