php - 在 Codeigniter 中包含 Zend 库

标签 php codeigniter zend-framework

所以我尝试安装一些 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 如下图: enter image description here

并将此代码粘贴到其中:

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/

相关文章:

javascript - AJAX 无法在 codeigniter 中加载同一 DIV 中的页面

php - Zend Framework 更改插件中的 View 位置

jquery - 输入前的 Zend 表单复选框标签

php - 如何在zend框架中对表进行分页?

php - 如何将大查询拆分为小查询并将它们作为单个查询附加

javascript - 验证名字和姓氏

java - 使用 ActiveMQ/Stomp 在 PHP 和 Java 之间进行通信

javascript - 表单提交按钮不起作用

php - CodeIgniter 中的胖模型瘦 Controller

php - CodeIgniter - 在更新记录时将默认值添加到数据库中的 form_dropdown