在Codeigniter中包含Zend库 - php

因此,我主要尝试安装一些Zend Framework组件,以便可以使用google API picasa库。

我试图将Zend库添加到我的

codeigniter->应用程序->库

然后运行$this->load->library('Zend');但我收到了

无法加载请求的类: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中。我究竟做错了什么?

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:是否有充分的理由引用所有数组键/索引? - php

我正在遍历别人的代码,他们总是避免转义其数组键。例如:$ row_rsCatalogsItems [名称]代替$ row_rsCatalogsItems ['名称']因此,我不断地对自己接触的所有事物进行微小的更改,以应对这些惰性。但是现在我想知道这样做是否有很多好处。我得到它会在默认为字符串之前检查常量(我在处理常量时会讨厌php中的行为,因为即使未定义,…

哪个更好的做法?从Jquery响应获取HTML - php

这只是一个问题,以了解人们如何以及如何做到这一点,但是假设用户向列表中添加了一些内容,完成后,它将运行下面的ajax并更新.user-stream-list$.ajax({ url: "user-stream-list.php", success: function(data){ $(".user-stream-list…

使用PHP从sqlite3数据库检索表名称 - php

我有此代码的工作版本,如下所示,结果为can be seen here。<?php // Display all sqlite tables $db = new SQLite3('data.db'); $tablesquery = $db->query("SELECT name FROM sqlite_master …

PHP标头功能不起作用 - php

我曾经使用此功能从一个PHP页面重定向到另一个:header( 'Location: student.php?cnp='.$_REQUEST['name']) ; 在我的本地主机中,它确实可以工作,但是如果在Internet中对其进行测试,则不会重定向。我也尝试给出完整的路径(如http://.../student.p…

PHP中的可选函数输入 - php

我注意到在一些内置的PHP函数中,例如str_replace,有一些可选的输入变量。我可以在自己的函数中有可选的输入变量吗?如果是这样,怎么办?谢谢,布赖恩 php参考方案 第一种方法是对某些参数使用默认值:function doStuff($required, $optional = '', $optional2 = '�…