找不到类'GuzzleHttp\Client' [英] Class 'GuzzleHttp\Client' not found

查看:761
本文介绍了找不到类'GuzzleHttp\Client'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次同时使用 Guzzle 和Codeigniter 3.0。我也承认我是第一次使用php名称空间。

I am using BOTH Guzzle and Codeigniter 3.0 for the first time. Also I admit I am using php namespace for the first time.

我试图根据文档中提供的示例使用Guzzle提出一个非常简单的get请求。 (Guzzle的文档对codeigniter没说什么。)

I am trying to make a very simple get request using Guzzle according to the examples provided in the docs. (The Guzzle docs say nothing about codeigniter).

Guzzle文件位于application / class / guzzle

The Guzzle files are located at application/class/guzzle

这是我非常简单的控制器

Here is my very simple controller

public function indey () {

        $data = array();
        $data['main_content'] = "hiview";
        $data['title'] = "Data Analyzer - Welcome";
        $data['xas'] = $this->guzzler();
        $this->load->view('template', $data);
    }

    private function guzzler() {
        $client = new GuzzleHttp\Client;
        $response = $client->get('http://guzzlephp.org');
        return $response;
    }

这是我的简单观点

    <div class="row">
        <div class="col-xs-12">
             <h1>Hi</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <h1><?php var_dump($xas); ?></h1>
        </div>
    </div>

这是我遇到的错误

遇到PHP错误
严重性:错误
消息:未找到类'GuzzleHttp\Client'
文件名:controllers / hello.php
行号:22
回溯:

推荐答案

application / config / config.php


$config['composer_autoload'] = FCPATH.'vendor/autoload.php';

对我来说很好

这篇关于找不到类'GuzzleHttp\Client'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆