所以我尝试安装一些 Zend Framework 组件,主要是为了可以使用 google API picasa 库。
我尝试将 Zend 库添加到我的
codeigniter-> application-> libraries
然后运行 $this->load->library('Zend');
但我收到了
Unable to load the requested class: zend
然后我尝试这样做
$clientLibraryPath = '/usr/local/lib/php/Zend/Gdata';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $clientLibraryPath);
错误
> Exception thrown trying to access Zend/Loader.php using
> 'use_include_path' = true. Make sure you include Zend Framework in
> your include_path which currently contains:
> .:/usr/share/php:/usr/share/pear:/usr/local/lib/php/Zend/Gdata
我不确定实际路径应该是什么我还将 Zend 库上传到 users/local/lib/php 。我做错了什么?
最佳答案
看这个: 您需要在库中创建文件Zend.php 如下图:
并将此代码粘贴到其中:
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class Zend
{
public function __construct($class = NULL)
{
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");
}
}
public function load($sClassName)
{
require_once (string) $sClassName . EXT;
log_message('debug', "-> Zend Class $sClassName Loaded from the library");
}
}
就是这样。现在从 Controller 中的方法调用您需要的库。 这里我展示了一个加载 Picasa 网络相册的示例。
$this->load->library('zend');
$this->zend->load('Zend/Loader');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Photos');
Zend_Loader::loadClass('Zend_Http_Client');
另一个加载 Google Spreedsheet 的示例。
$this->load->library('zend');
$this->zend->load('Zend/Gdata/Spreadsheets');
$oSpreadSheet = new Zend_Gdata_Spreadsheets();
$entry = $oSpreadSheet->newCellEntry();
$cell = $oSpreadSheet->newCell();
$cell->setText('My cell value');
$cell->setRow('1');
$cell->setColumn('3');
$entry->cell = $cell;
var_dump( $entry );
了解更多信息see this
关于php - 在 Codeigniter 中包含 Zend 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17846671/