你好,我正在测试的终点,当我运行PHP testing.php我得到这个错误。任何帮助,将不胜感激它。
Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 7: Failed to connect to localhost port 8000: Connection refused [url] http://localhost:8000/api/programmers' guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php:359 ...
我试过127.0.0.1以及和它没有工作
这里是testing.php
<?php
require __DIR__.'/vendor/autoload.php';
use Guzzle\Http\Client;
// create our http client (Guzzle)
$client = new Client('http://localhost:8000', array(
'request.options' => array(
'exceptions' => false,
)
));
$nickname = 'ObjectOrienter'.rand(0, 999);
$data = array(
'nickname' => $nickname,
'avatarNumber' => 5,
'tagLine' => 'a test dev!'
);
$request = $client->post('/api/programmers', null, json_encode($data));
$response = $request->send();
echo $response;
echo "\n\n";
如果你使用的是Linux,确保服务器使用运行
/etc/init.d/httpd status
我面临同样的,当http://localhost:8000或http://127.0.0.1:8000既不工作。我解决了使用我的网络IP喜欢它
192.168.0.3:8000
请检查您的本地主机:8000服务器正在运行。 如果不是使用以下从终端命令然后启动它。 转到根项目及类型的文件夹,
php -S localhost:8000 -t .\public
如果你像这样运行的本地主机:
PHP -S本地主机:8000
然后从不同的环境,比如游民,然后在你的流浪汉本地主机上运行卷曲是不一样的本地计算机上的本地主机。