【问题标题】:Error codeception requires CURL extension installed错误代码接收需要安装 CURL 扩展
【发布时间】:2014-12-03 05:24:33
【问题描述】:

好的,我正在使用 laravel 5 浏览 Larabook 上的教程系列,但我一直在尝试使用 Codeception。我的 laravel 应用程序文件夹名称是“larabook”

从我的 larabook 文件夹中运行 vendor/bin/codecept 可以正常工作,为我提供选项列表。然后我对其进行了初始化,并且成功了。我按照说明创建了一个 SignUpCept.php 文件,并在其中填写了以下内容。

<?php 

$I = new FunctionalTester($scenario);
$I->am('a guest');
$I->wantTo('Sign up for a Larabook acount');

$I->amOnPage('/');
$I->click('Sign Up');
$I->seeCurrentUrlEquals('/register');

$I->fillField('Username:', 'JohnDoe');
$I->fillField('Email:', 'john@example.com');
$I->fillField('Password:', 'demo');
$I->fillField('Password Confirmation:', 'demo');
$I->click('Sign Up');

$I->seeCurrentUrlEquals('');
$I->see('Welcome to Larabook!');

但是当我运行“vendor/bin/codecept run functional”时,我得到以下错误..

[Exception]
Codeception requires CURL extension installed to make tests run.

现在,如果我键入 curl --help 我会得到选项列表,这意味着它已正确安装,为什么会发生这种情况?我正在使用带有 vagrant 和 virtualbox 以及 laravel 5 的 windows。

我的“测试”文件夹位于 larabook 文件夹的根目录中,我的 codeception.yml 文件如下所示。

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    helpers: tests/_support
settings:
    bootstrap: _bootstrap.php
    colors: false
    memory_limit: 1024M
modules:
    config:
        Db:
            dsn: ''
            user: ''
            password: ''
            dump: tests/_data/dump.sql

我的 .env.testing.php 也正确设置在 larabook 的根目录中。

【问题讨论】:

    标签: curl laravel codeception laravel-5


    【解决方案1】:

    就像@Alan 所说,如果你还没有为 php 安装 curl,在我遇到类似错误的情况下,我只是用这个(在 Ubuntu 15.10 上)安装它,然后我的代码接收测试运行

    sudo apt-get install php5-curl
    

    PS:如果你已经在 root 访问,你不需要 sudo

    【讨论】:

      【解决方案2】:

      跑步

      $ curl --help 
      

      表示你的系统上安装了 unix 命令行 curl 程序。

      这也意味着你的系统上安装了 unix curl 库。

      它不意味着您的 PHP 系统上安装了 PHP curl 扩展。

      使用以下 PHP 代码创建一个小测试文件

      phpinfo();
      

      它将列出 PHP 已安装的所有扩展。我的猜测是没有安装 PHP curl 扩展。

      请记住,您使用的 PHP 命令行版本可能与您使用的 PHP 网络版本不同。

      【讨论】:

      • 啊,好吧,我知道我必须在 php.ini 中启用扩展。谢谢!
      【解决方案3】:

      如果你使用phpbrew,你可以安装 curl 扩展:

      phpbrew ext install curl
      

      如果出现错误安装这个库:

      sudo apt install libcurl4-openssl-dev
      

      注意:此解决方案已在 Ubuntu 16 上测试

      【讨论】:

        猜你喜欢
        • 2014-01-29
        • 2023-01-21
        • 1970-01-01
        • 1970-01-01
        • 2014-09-20
        • 2012-01-17
        • 2011-05-25
        • 2011-09-21
        • 1970-01-01
        相关资源
        最近更新 更多