Reputation: 433
I need to make POST request, can I do it via PHP artisan?
I tried this using GuzzleHttp
, but I get error:
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...)
So, is it possible with artisan?
Upvotes: 4
Views: 6622
Reputation: 558
Instead of using tinker, why not run a local server and make a request to it?
php artisan tinker serve
Upvotes: 0
Reputation: 2107
Not sure how efficient my method is, but this is an example I have run in the past.
Go into project directory.
Type php artisan tinker
Create an array of paramaters to pass:
$params = ['paramOne' => 'valueOne', 'paramTwo' => 'valueTwo'];
$request = Illuminate\Http\Request::create($uri, $method, $params);
$request = App\Http\Requests\MyExtendedRequest::create($uri, $methodType, $params);
$uri
is where you want to send the request
$methodType
is the type of HTTP Method to use (GET, POST, PUT, etc)
$controller = new App\Http\Controllers\MyController;
$response = $controller->storeMission($request);
Upvotes: 15