a helper and facade for making internal sub requests to your application API
By sending a sub request within the application, you can simply consume your applications API without having to send seperate, slower HTTP requests.
You can install this package via composer:
composer require myerscode/laravel-sub-request
The package will be auto discovered.
Add Myerscode\Laravel\SubRequest\SubRequestProvider
to the providers
array in config/app.php
In your controller you can inject the sub request component into your class or use the SubRequest
facade or the global helper method subrequest
.
namespace App\Controllers;
class MyController {
public function __contstruct(Dispatcher $subRequest) {
$this->subRequest = $subRequest;
}
public function routeOne() {
return $this->subRequest->dispatch('POST', '/auth', ['foo' => 'bar'])
}
public function routeTwo() {
return SubRequest::dispatch('GET', '/details', ['foo' => 'bar'])
}
public function routeThree() {
return subrequest('GET', '/details', ['foo' => 'bar'])
}
...
}