Download the PHP package matbcvo/laravel-token-auth without Composer
On this page you can find all versions of the php package matbcvo/laravel-token-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-token-auth
Laravel Token Auth
A lightweight package that simplifies API token management in your Laravel applications. It provides Artisan commands and middleware support to create, manage, and authenticate API tokens efficiently.
Features
- Create API tokens: Generate and store new API tokens.
- List API tokens: View existing tokens with their details.
- Delete API tokens: Remove existing tokens with confirmation prompts.
- Middleware integration: Secure your API routes with a simple token-based authentication middleware.
Installation
Install the package via Composer:
Publish the migration files to your application's database/migrations
directory:
Run the migrations to create the api_tokens
table in your database:
Middleware
To secure your routes using the provided middleware, you can authenticate API requests based on a token.
Apply middleware to API routes
The package registers a middleware alias auth.token
. You can use this alias:
You can use the middleware class directly for explicit clarity:
Commands
This package provides the following Artisan commands:
Create a new API token
To generate and save a new API token, use the following command:
Parameters:
-
name
(required): This is the descriptive name for the token, useful for identifying its purpose. --expires
(optional): The token's expiration time in minutes. If not provided, the token will not expire.
List all API tokens
View all existing API tokens:
Delete an API token
Delete a specific API token by its ID:
You’ll be asked to confirm before deletion.
Configuration
The package provides a configuration file to customize its behavior. To publish the configuration file, run:
Available configuration options
The configuration file includes the following options:
-
Token length
Defines the length of the API token. By default, it is set to 60 characters.
Contribution
Contributions are welcome! If you encounter issues or have feature requests, please submit them via GitHub issues.
License
This package is open-source and available under the MIT License.