我同时使用Guzzle http://guzzle.readthedocs.org/en/latest/并首次推出 Codeigniter 3.0。我也承认我是第一次使用 php 命名空间。
我正在尝试根据文档中提供的示例使用 Guzzle 发出一个非常简单的获取请求。 (Guzzle 文档没有提及 codeigniter)。
Guzzle 文件位于 application/class/guzzle
这是我非常简单的控制器
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
回溯:
In application/config/config.php
$config['composer_autoload'] = FCPATH.'vendor/autoload.php';
对我来说效果很好
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)