736074781

415 经验值

在开发 Laravel package时,引入了GuzzleHttp,但是再 new client 时报错:

>>> app('ipconversion')
=> VavoCake\IpConversion\IpConversion {#2824}
>>> app('ipconversion')->convert('183.160.92.159')
PHP Error:  Class 'VavoCake/IpConversion/GuzzleHttp/Client' not found in /home/vagrant/Code/packagetest/packages/vavocake/ipconversion/src/Traits/HttpRequestTrait.php on line 20

引用代码:

<?php

namespace VavoCake\IpConversion\Traits;

use GuzzleHttp\Client;

class HttpRequestTrait
{
    public function get($ip)
    {
        $client = $this->getHttpClient([
            'base_uri' => config('ipconversion.url')
        ]);
        $response = $client->request('GET', $this->makeParams($ip));
        return $response;
    }

    protected function getHttpClient(array $options)
    {
        return new Client($options);
    }

请问为什么我不论是通过环境变量执行 vendor/bin/phpunit, 还是直接 cd 进去执行 phpunit,都是提示:
You need to set up the project dependencies using Composer:

composer install

You can learn all about Composer on https://getcomposer.org/.
@JellyBool