Download the PHP package rdcstarr/laravel-easyapi without Composer
On this page you can find all versions of the php package rdcstarr/laravel-easyapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rdcstarr/laravel-easyapi
More information about rdcstarr/laravel-easyapi
Files in rdcstarr/laravel-easyapi
Package laravel-easyapi
Short Description A simple settings package for Laravel.
License MIT
Homepage https://github.com/rdcstarr/laravel-easyapi
Informations about the package laravel-easyapi
Laravel EasyAPI
Lightweight package for managing API keys in Laravel โ with middleware protection, logging and simple CLI tools.
โจ Features
- ๐ API key management โ generate, list, reveal and delete API keys via an artisan command or programmatically.
- ๐ก Middleware protection โ a lightweight middleware validates Bearer tokens on incoming requests.
- ๐ Usage metrics โ each key tracks an access count and API access is logged to
api_logs. - ๐ Secure keys โ keys are generated using SHA-256 with unique identifiers to avoid collisions.
- โ๏ธ Facade & manager โ programmatic API via the
EasyApifacade or theEasyApiManagerservice. - ๐งช Test-friendly โ models and factories included to make testing straightforward.
- ๐ฆ Migrations included โ package ships migrations for
apiandapi_logstables and can be published.
๐ฆ Installation
Automatic Installation (Recommended)
Run the install command to publish and run the migrations:
Manual Installation
Alternatively, you can install manually:
-
Publish the migrations:
- Run the migrations:
The package registers a singleton manager and console commands. It will also register route groups if you provide routes/api.php or routes/web.php.
๐ Usage
Facade examples (programmatic):
Middleware usage:
- The package provides
Rdcstarr\EasyApi\Middleware\EasyApiMiddlewarewhich checks for a Bearer token and validates it against theapitable. If valid, it logs the request and increments the access count.
Apply it to a route or route group:
Database schema:
apitable: id, key (unique), access_count, timestampsapi_logstable: id, api_id, endpoint, ip_address, user_agent, timestamps
Artisan CLI:
The package exposes a single console command: php artisan easyapi with the following actions:
- generate โ create a new API key
- delete --key=KEY โ delete an API key (confirmation required)
- list โ display stored API keys (masked) with access counts
- reveal --id=ID โ reveal the full API key for a given id
Examples:
Notes:
- Generated keys must be stored securely when created โ the
generatecommand shows the full key once. - The command output masks keys in listings for safety; use
revealto show the full value when necessary.
๐งช Testing
Run the package tests:
The package provides models (Api, ApiLog) and factories to make writing tests simpler.
๐ Resources
- Changelog for more information on what has changed recently.
๐ฅ Credits
๐ License
- License for more information.
All versions of laravel-easyapi with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0