尝试在Windows上使用PEAR安装Predis

时间:2014-09-04 11:08:50

标签: php codeigniter pear predis

首先,我是PEAR和Predis的新手...我想在Windows 7上安装Predis,以及到目前为止我所做的... 我在C:/ Redis上的计算机上安装了Redis。 PEAR位于\ wamp \ bin \ php \ php5.3.10中,并且已成功安装。 现在我尝试使用

安装Predis
pear install nrk/Predis-1.0.0

它给了我以下错误

downloading Predis-1.0.0.tar ...
Starting to download Predis-1.0.0.tar (2,014,208 bytes)
...............................done: 2,014,208 bytes

Warning: require_once(Structures/Graph.php): failed to open stream: No such file
 or directory in PEAR\Downloader.php on line 1192
PHP Warning:  require_once(Structures/Graph.php): failed to open stream: No such
 file or directory in C:\wamp\bin\php\php5.3.10\pear\PEAR\Downloader.php on line
 1192
PHP Stack trace:
PHP   1. {main}() C:\wamp\bin\php\php5.3.10\pear\pearcmd.php:0
PHP   2. PEAR_Command_Common->run() C:\wamp\bin\php\php5.3.10\pear\pearcmd.php:3
07
PHP   3. PEAR_Command_Install->doInstall() C:\wamp\bin\php\php5.3.10\pear\PEAR\C
ommand\Common.php:271
PHP   4. PEAR_Downloader->sortPackagesForInstall() C:\wamp\bin\php\php5.3.10\pea
r\PEAR\Command\Install.php:699

Warning: require_once(Structures/Graph.php): failed to open stream: No such file
 or directory in C:\wamp\bin\php\php5.3.10\pear\PEAR\Downloader.php on line 1192


Call Stack:
    0.0010     881520   1. {main}() C:\wamp\bin\php\php5.3.10\pear\pearcmd.php:0

    0.0597    4753144   2. PEAR_Command_Common->run() C:\wamp\bin\php\php5.3.10\
pear\pearcmd.php:307
    0.0597    4753144   3. PEAR_Command_Install->doInstall() C:\wamp\bin\php\php
5.3.10\pear\PEAR\Command\Common.php:271
   11.4545   13810008   4. PEAR_Downloader->sortPackagesForInstall() C:\wamp\bin
\php\php5.3.10\pear\PEAR\Command\Install.php:699

PHP Fatal error:  require_once(): Failed opening required 'Structures/Graph.php'
 (include_path='C:\wamp\bin\php\php5.3.10\pear') in C:\wamp\bin\php\php5.3.10\pe
ar\PEAR\Downloader.php on line 1192
PHP Stack trace:
PHP   1. {main}() C:\wamp\bin\php\php5.3.10\pear\pearcmd.php:0
PHP   2. PEAR_Command_Common->run() C:\wamp\bin\php\php5.3.10\pear\pearcmd.php:3
07
PHP   3. PEAR_Command_Install->doInstall() C:\wamp\bin\php\php5.3.10\pear\PEAR\C
ommand\Common.php:271
PHP   4. PEAR_Downloader->sortPackagesForInstall() C:\wamp\bin\php\php5.3.10\pea
r\PEAR\Command\Install.php:699

Fatal error: require_once(): Failed opening required 'Structures/Graph.php' (inc
lude_path='C:\wamp\bin\php\php5.3.10\pear') in C:\wamp\bin\php\php5.3.10\pear\PE
AR\Downloader.php on line 1192

Call Stack:
    0.0010     881520   1. {main}() C:\wamp\bin\php\php5.3.10\pear\pearcmd.php:0

    0.0597    4753144   2. PEAR_Command_Common->run() C:\wamp\bin\php\php5.3.10\
pear\pearcmd.php:307
    0.0597    4753144   3. PEAR_Command_Install->doInstall() C:\wamp\bin\php\php
5.3.10\pear\PEAR\Command\Common.php:271
   11.4545   13810008   4. PEAR_Downloader->sortPackagesForInstall() C:\wamp\bin
\php\php5.3.10\pear\PEAR\Command\Install.php:699

1 个答案:

答案 0 :(得分:1)

好吧..经过大量的搜索......我在Windows 7上使用Composer安装了Predis。 以下是w.r.t Wamp服务器。

首先,在php.ini中启用php_openssl 我遵循的步骤是,

  1. 将Redis从[here] https://github.com/rgl/redis/downloads安装到文件夹,例如C:/ Redis
  2. 从您网站的根目录[here] https://getcomposer.org/download/安装Composer。
  3. 在你网站的根目录下载Composer.phar ..抱歉..我没有给那个链接添加书签..所以我没有它.. :(
  4. 编写此文件composer.json

    {“require”:{     “predis / predis”:“1.1.*@dev” }}

  5. 并运行此命令

    php composer.phar install
    

    从您放置这些文件的文件夹(composer.phar和composer.json).. 之后,在php.ini(apache和php)中编写这个include_path:

    include_path='.;C:\wamp\www\vendor\predis'
    

    现在编写此代码来测试predis

    <?php
    require("predis/autoload.php");
    Predis\Autoloader::register();
    try {
    $redis = new Predis\Client(array(
        "scheme" => "tcp",
        "host" => "127.0.0.1",
        "port" => 6379));
    
    echo "Successfully connected to Redis";
    echo $redis->ping();
    }
    catch (Exception $e) {
        echo "Couldn't connected to Redis";
    echo $e->getMessage();
    }
    
    祝你好运! :)