Guzzle Http Client找不到类

问题描述 投票:1回答:2

这是一个不断发生的奇怪错误。

致命错误:在第15行的/home/futcoins/public_html/autobuyer/classes/shopify.php中找不到类'Guzzle \ Http \ Client'

这是源代码。我认为这个问题很简单,我已经坚持了几天这个问题,任何想法?

use Guzzle\Http\Client;
use Guzzle\Plugin\Cookie\CookiePlugin;
use Guzzle\Plugin\Cookie\CookieJar\FileCookieJar;

class Shopify {

        //initialise the class
    public function __construct() {
    }

    public function GetOrders() {       

        $client = new Client(null); //Line 15 where errors occurs
        $request = $client->get("url"); 
        $response = $request->send();
        $json = $response->json();
        return $json;
    }
}
php autoload
2个回答
1
投票

所以你在顶部有一个声明

use Guzzle\Http\Client;

这意味着您要么拥有自动加载器,要么手动包含相应的文件。因此,您需要找到具有该类的文件并将其包含在内,否则PHP将会查找您未提供给它的代码。


1
投票

我不确定它是否适合您,但我有完全相同的问题并修复它我更新了我的服务器上的composer并重新生成了自动加载文件:

sudo /usr/bin/composer.phar self-update
/usr/bin/composer.phar dump-autoload

我不确定它是否有必要,但我也重新启动了apache:

sudo /etc/init.d/httpd restart

为了防止将来发生这种情况并且因为我们正在使用Elastic Beanstalk,我创建了一个配置文件以确保该编写器是最新的:

commands:
  01updateComposer:
    command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: COMPOSER_HOME
    value: /root

资料来源:http://blogs.aws.amazon.com/php/post/Tx2M04LCN1UEE0E/Reduce-Composer-Issues-on-Elastic-Beanstalk

© www.soinside.com 2019 - 2024. All rights reserved.