Php 在XAMPP问题中使用Zend框架和CodeIgniter
本文解释了如何在Codeigniter中使用Zend 我正在使用XAMPP,在使用path时遇到困难 问题1。我不知道这里发生了什么事。为什么我需要设置这个Php 在XAMPP问题中使用Zend框架和CodeIgniter,php,zend-framework,codeigniter,Php,Zend Framework,Codeigniter,本文解释了如何在Codeigniter中使用Zend 我正在使用XAMPP,在使用path时遇到困难 问题1。我不知道这里发生了什么事。为什么我需要设置这个 ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries'); 问题2。经过一些调整后,我将上述代码更改为以下代码 ini_set('include_path', ini_get('include_path') . PAT
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries');
问题2。经过一些调整后,我将上述代码更改为以下代码
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . BASEPATH . 'libraries');
上述行的输出为
)。;C:\xampp\php\pear\;应用程序\库
但是,我得到一个错误,例如
消息:require_once(Zend/Validate/Between.php)[function.require once]:无法打开流:没有这样的文件或目录
文件名:Service/Flickr.php
及
致命错误:require_once()[function.require]:无法在C:\xampp\htdocs\ci_day6_working_copy\application\libraries\Zend\Service\Flickr.php第476行打开所需的“Zend/Validate/Between.php”(include_path=”;C:\xampp\php\pear\;C:\xampp\htdocs\ci_day6_working_copy\system\libraries”)
原始代码:
<?php if (!defined('BASEPATH')) {exit('No direct script access allowed');}
/**
* Zend Framework Loader
*
* Put the 'Zend' folder (unpacked from the Zend Framework package, under 'Library')
* in CI installation's 'application/libraries' folder
* You can put it elsewhere but remember to alter the script accordingly
*
* Usage:
* 1) $this->load->library('zend', 'Zend/Package/Name');
* or
* 2) $this->load->library('zend');
* then $this->zend->load('Zend/Package/Name');
*
* * the second usage is useful for autoloading the Zend Framework library
* * Zend/Package/Name does not need the '.php' at the end
*/
class CI_Zend
{
/**
* Constructor
*
* @param string $class class name
*/
function __construct($class = NULL)
{
// include path for Zend Framework
// alter it accordingly if you have put the 'Zend' folder elsewhere
ini_set('include_path',
ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries');
if ($class)
{
require_once (string) $class . EXT;
log_message('debug', "Zend Class $class Loaded");
}
else
{
log_message('debug', "Zend Class Initialized");
}
}
/**
* Zend Class Loader
*
* @param string $class class name
*/
function load($class)
{
require_once (string) $class . EXT;
log_message('debug', "Zend Class $class Loaded");
}
}
?>
Q1:这是将CodeIgniter的应用程序/库文件夹添加到PHP的include_路径。如果您不熟悉include_path,请查看。将文件夹添加到include_路径意味着您不必在包含文件时指定路径
问题2:除非您修改了它们的定义,否则APPPATH和BASEPATH不是一回事。出现此错误的原因是,它没有查找您链接的教程中表示要放置Zend Framework文件的应用程序/库,而是查找系统/库。APPPATH是相对的,但您需要应用程序库目录的绝对路径。您可以在index.php引导文件中进行以下更改:
if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
{
// comment out this code:
// $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
// add this code:
$root = str_replace("\\", "/", realpath(dirname(__FILE__))).'/';
$application_folder = $root . $application_folder;
$system_folder = $root . $system_folder;
unset($root);
}