在Codeigniter中包含Zend库 [英] Including Zend Library within Codeigniter
问题描述
所以我主要尝试安装一些Zend Framework组件,以便可以使用google API picasa库.
So I'm attempting to install some Zend Framework components mainly so I can use the google API picasa library.
我尝试将Zend库添加到我的
I tried adding the Zend library to my
codeigniter->应用程序->库
codeigniter-> application-> libraries
然后运行 $ this-> load-> library('Zend');
,但我收到
无法加载请求的类: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 中.我在做什么错了?
I'm not sure on what the actual path should be I also uploaded the Zend libary into users/local/lib/php as well. What am I doing wrong?
推荐答案
查看此内容:您需要在库中创建文件 Zend.php 如下图所示:
See this: you need to create file Zend.php in libraries as image below:
并将此代码放入其中:
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网络相册的示例.
That’s it. Now call library what you need from your method in Controller. Here I show one example to load Picasa Web Albums.
$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 );
更多信息,参见
这篇关于在Codeigniter中包含Zend库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!