I'm using zend framework with log4php and smarty, I've encountered the following problem while trying to run bootstrap of Zend.
This is the error I get:
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'
I think my problem is quite similar to the following mentioned here, however this bug was already solved and fixed and I saw the fix is similar to what James was writing there. Anyway this is not working as you can see , so I wonder what else should I try.
Here is my config.php code:
/** *
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";
}
Assuming you installed ZF2 using Composer, it'll make your life easier if you install log4php and Smarty with it as well. Update your
composer.json
and add update your existing require section to add the two other libraries to it:Then run
php composer.phar install
. Then composer can handle the autoloading and you don't need to do anything with include paths orspl_autoload_register()
.