API consumers for Laravel offering Eloquent style syntax
, (*1)
This Laravel package lets you generate API Consumers with Endpoints and Shapes which usage is similar to Laravel's Eloquent models., (*2)
You can generate one Consumer per API service you want to consume. Each Consumer can have any number of Endpoints with multiple Shapes., (*3)
An Endpoint represents e.g. a resource on a REST API like /users. Endpoints return Collections of Shapes. You can model the methods the API offers here., (*4)
A Shape represents an Object returned by an Endpoint and allows you to e.g. transform or validate the Object's properties., (*5)
Disclaimer
This package is currently in development and is not production ready., (*6)
Installation
You can install the package via composer, (*7)
composer require black-bits/laravel-api-consumer
Next you can publish the config, (*8)
php artisan vendor:publish --provider="BlackBits\ApiConsumer\ApiConsumerServiceProvider"
Usage
To make a new Api Consumer Service you can simply run
``` bash
php artisan make:api-consumer ConsumerName, (*9)
To add an endpoint (e.g. UserEndpoint) to this service run the following command, this will also create a default shape (UserShape) for that Endpoint
``` bash
php artisan make:api-consumer-endpoint UserEndpoint -c ConsumerName
To add a custom Collection Callback run the following command.
You can use this e.g. to create a filter that only shows Users that receive a newsletter
``` bash
php artisan make:api-consumer-collection-callback ReceivesNewsletter, (*10)
You can find an example implementation here: [black-bits/laravel-api-consumer-showcase](https://github.com/black-bits/laravel-api-consumer-showcase)
### Testing
``` bash
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently., (*11)
Security
If you discover any security related issues, please email hello@blackbits.io instead of using the issue tracker., (*12)
Credits
Support us
Black Bits, Inc. is a web and consulting agency specialized in Laravel and AWS based in Grants Pass, Oregon. You'll find an overview of what we do on our website., (*13)
License
The MIT License (MIT). Please see License File for more information., (*14)