https://github.com/matthewbdaly/laravel-internal-requests
Make internal requests against your Laravel application
https://github.com/matthewbdaly/laravel-internal-requests
laravel laravel-5-package php
Last synced: 7 months ago
JSON representation
Make internal requests against your Laravel application
- Host: GitHub
- URL: https://github.com/matthewbdaly/laravel-internal-requests
- Owner: matthewbdaly
- License: mit
- Created: 2017-11-18T15:48:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-20T20:15:37.000Z (over 6 years ago)
- Last Synced: 2024-10-26T13:44:41.690Z (7 months ago)
- Topics: laravel, laravel-5-package, php
- Language: PHP
- Size: 15.6 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-internal-requests
[](https://travis-ci.org/matthewbdaly/laravel-internal-requests)
[](https://coveralls.io/github/matthewbdaly/laravel-internal-requests?branch=master)Make internal requests against your Laravel application.
Installation
------------```
composer require matthewbdaly/laravel-internal-requests
```What do I want this for?
------------------------I've used this approach for a mobile app that had offline functionality. Every time it made a change to some data, it needed to be able to store the changes locally. Then, when the app was online again, it needed to send the changes up in a batch so that they could be synced. I created a sync endpoint that used something like this to loop through every request in the batch and process it all in one go. If one failed, I could then catch the exception and persist the unsynced changes in a table in the database so that they could be resolved later without losing the data.
I honestly can't think of any other situation where you'd want to use this approach, but someone else may.
Usage
-----Type-hint the interface `Matthewbdaly\LaravelInternalRequests\Contracts\Services\MakesInternalRequests` to retrieve the internal request service. Then use it as follows:
```php
$service->request('POST', '/api/resource', ['content' => 'blah']);
```Any one request accepts three arguments:
* The HTTP verb to use
* The route to hit
* The payload (optional)