italofantone/api-token-validator

A simple package to validate API tokens with Laravel. Middleware to protect routes using valid tokens.

v1.0.1 2024-12-18 13:44 UTC

This package is auto-updated.

Last update: 2025-04-18 14:54:15 UTC


README

A simple package to validate API tokens with Laravel. Middleware to protect routes using valid tokens.

⚠️ This code was used for educational purposes [...]

Installation

You can install the package via composer. Run the following command:

composer require italofantone/api-token-validator

Usage

File .env: API_TOKEN_VALIDATOR=secret.

<?php

use Illuminate\Support\Facades\Route;
use Italofantone\ApiTokenValidator\Http\Middleware\EnsureApiTokenIsValid;

Route::get('protected-route', function () {
    return response()->json([
        'message' => 'You are authorized to access this route!',
    ]);
})
->middleware(EnsureApiTokenIsValid::class)
->name('protected-route');

Contact

Donations

If you find this project useful and would like to support its development, you can make a donation via PayPal:

Thank you for your support!