glocurrency/api-layer

This package is abandoned and no longer maintained. No replacement package was suggested.

Basic API package.

v0.1-alpha 2020-07-14 05:03 UTC

This package is auto-updated.

Last update: 2020-09-14 06:11:33 UTC


README

Total Downloads Latest Stable Version License

Installation

composer require glocurrency/api-layer

Passport

This module use Laravel Passport heavily. In order to make it work properly, follow the steps:

  1. Run
php artisan glo:apilayer:passport

This command will:

  • generate the keys
  • copy the migrations from passport
  • replace both client_id and user_id columns in migrations with UUID.
  1. Copy the passport middlewares to the $routeMiddleware in your app/Http/Kernel.php file:
'client' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,
  1. Add the following code to the boot method of AuthServiceProvider:
use Glocurrency\ApiLayer\ApiLayer;

public function boot()
{
    $this->registerPolicies();

    ApiLayer::passport();
}
  1. Generate both Client and Personal grant tokens.
php artisan passport:client --client
php artisan passport:client --personal

After creating your personal access client, place the client's ID and plain-text secret value in your application's .env file:

PASSPORT_PERSONAL_ACCESS_CLIENT_ID=client-id-value
PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET=unhashed-client-secret-value
  1. Use UnauthenticatedTrait in your app/Exceptions/Handler.php file:
use Glocurrency\ApiLayer\Traits\UnauthenticatedTrait;

class Handler extends ExceptionHandler
{
    use UnauthenticatedTrait;

License

Glocurrency Api Layer is open-sourced software licensed under the MIT license.

FOSSA Status