gtk / gapi
A RESTful API package for the Laravel and Lumen frameworks.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: >=5.4.0
- illuminate/contracts: ~5.0
- illuminate/database: ~5.0
- illuminate/http: ~5.0
- illuminate/support: ~5.0
- league/fractal: ^0.13.0
Requires (Dev)
- mockery/mockery: 0.9.9
- phpunit/phpunit: ~4.0
Suggests
- barryvdh/laravel-cors: Allow you to send Cross-Origin Resource Sharing headers with ACL-style per-url configuration.
- tymon/jwt-auth: Protect your API with JSON Web Tokens.
This package is not auto-updated.
Last update: 2024-06-08 18:10:55 UTC
README
Gapi provides a simple, convenient way to handle your API response properly.
Install
Install via composer - edit your composer.json
to require the package.
"require": {
"gtk/gapi": "dev-master"
}
Then run composer update
in your terminal to pull it in.
Once this has finished, you will need to add the service provider to the providers array in your config/app.php
file as follows:
'providers' => [
// Other service providers...
Gtk\Gapi\GapiServiceProvider::class,
],
If you are using Lumen, register the Gtk\Gapi\GapiServiceProvider
in your bootstrap/app.php
file:
// $app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
$app->register(Gtk\Gapi\GapiServiceProvider::class);
Basic Usage
Next, you are ready to response API results for your application with api_response()
helper function:
class FooController extends Controlelr
{
// some code ...
return api_response()->json([
'success' => true,
]);
}
License
Gapi is open-sourced software licensed under the MIT license.