API consumers for Laravel offering Eloquent style syntax
This Laravel package lets you generate API Consumers with Endpoints and Shapes which usage is similar to Laravel's Eloquent models.
You can generate one Consumer per API service you want to consume. Each Consumer can have any number of Endpoints with multiple Shapes.
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.
A Shape represents an Object returned by an Endpoint and allows you to e.g. transform or validate the Object's properties.
This package is currently in development and is not production ready.
You can install the package via composer
composer require black-bits/laravel-api-consumer
Next you can publish the config
php artisan vendor:publish --provider="BlackBits\ApiConsumer\ApiConsumerServiceProvider"
To make a new Api Consumer Service you can simply run
php artisan make:api-consumer ConsumerName
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
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
php artisan make:api-consumer-collection-callback ReceivesNewsletter
You can find an example implementation here: black-bits/laravel-api-consumer-showcase
Please see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email firstname.lastname@example.org instead of using the issue tracker.
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.
The MIT License (MIT). Please see License File for more information.