Gri*_*dov 1 laravel laravel-5.2
我需要发出 POST 请求,我可以通过 PHP artisan 来完成吗?
我尝试使用GuzzleHttp,但出现错误:
ServerException in RequestException.php line 107:
Server error: `POST http://localhost/public/api/order` resulted in a `500 Internal Server Error` response:
<!DOCTYPE html>
<html>
<head>
<meta name="robots" content="noindex,nofollow" />
<style>
(truncated...)
Run Code Online (Sandbox Code Playgroud)
那么,工匠可以吗?
不确定我的方法有多有效,但这是我过去运行过的一个例子。
进入项目目录。
类型 php artisan tinker
创建要传递的参数数组:
$params = ['paramOne' => 'valueOne', 'paramTwo' => 'valueTwo'];
$request = Illuminate\Http\Request::create($uri, $method, $params);
$request = App\Http\Requests\MyExtendedRequest::create($uri, $methodType, $params);
$uri是您要发送请求的位置
$methodType是要使用的 HTTP 方法的类型(GET、POST、PUT 等)
$controller = new App\Http\Controllers\MyController;
$response = $controller->storeMission($request);