Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/myerscode/laravel-sub-request
A helper and facade for making internal API sub requests to your application
https://github.com/myerscode/laravel-sub-request
facade helper laravel sub-request
Last synced: about 2 months ago
JSON representation
A helper and facade for making internal API sub requests to your application
- Host: GitHub
- URL: https://github.com/myerscode/laravel-sub-request
- Owner: myerscode
- License: mit
- Created: 2017-10-05T21:52:27.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-09-21T10:38:34.000Z (over 1 year ago)
- Last Synced: 2024-11-28T21:44:47.536Z (about 2 months ago)
- Topics: facade, helper, laravel, sub-request
- Language: PHP
- Size: 16.6 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Sub Request
a helper and facade for making internal sub requests to your application API[![Latest Stable Version](https://poser.pugx.org/myerscode/laravel-sub-request/v/stable)](https://packagist.org/packages/myerscode/laravel-sub-request)
[![Total Downloads](https://poser.pugx.org/myerscode/laravel-sub-request/downloads)](https://packagist.org/packages/myerscode/laravel-sub-request)
[![License](https://poser.pugx.org/myerscode/laravel-sub-request/license)](https://packagist.org/packages/myerscode/laravel-sub-request)By sending a sub request within the application, you can simply consume your applications API without having to send seperate, slower HTTP requests.
## Install
You can install this package via composer:
``` bash
composer require myerscode/laravel-sub-request
```## Setup
#### Laravel >=5.5
The package will be auto discovered.#### Laravel 5.4
Add `Myerscode\Laravel\SubRequest\SubRequestProvider` to the `providers` array in `config/app.php`## Usage
In your controller you can inject the sub request component into your class or use the `SubRequest` facade or the global helper method `subrequest`.
```php
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'])
}
...
}
```