PHPackages                             ibra4/api-key - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ibra4/api-key

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ibra4/api-key
=============

Provides api key for authenticatable models

0.0.9(2y ago)4199MITPHP

Since Mar 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ibra4/api-key)[ Packagist](https://packagist.org/packages/ibra4/api-key)[ RSS](/packages/ibra4-api-key/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (10)Used By (0)

[![StandWithPalestineBadge](https://raw.githubusercontent.com/saedyousef/StandWithPalestine/main/badges/flat/IStandWithPalestine.svg)](https://techforpalestine.org/learn-more)

Laravel API Key Authentication Package
======================================

[](#laravel-api-key-authentication-package)

This Laravel package provides a simple API key authentication mechanism for your Laravel applications. It allows you to protect your API endpoints by validating API keys sent with each request.

Requirements
------------

[](#requirements)

- PHP 7.3 or higher

Tested on Laravel ^8.75

Installation
------------

[](#installation)

You can install this package via Composer:

```
composer require ibra4/api-key
```

Next, you should publish the package's configuration file:

```
php artisan vendor:publish --tag=api_key
```

Then run migrations

```
php artisan migrate
```

This command will publish the `api_key.php` configuration file to your `config` directory.

Configuration
-------------

[](#configuration)

After publishing the configuration file, you can modify the settings in `config/api_key.php` to fit your application's requirements. This file allows you to define various aspects of API key authentication, such as key length, expiration duration, etc.

Usage
-----

[](#usage)

### Prepare your model

[](#prepare-your-model)

- Implement `HasApiKeyInterface` interface
- Use `HasApiKey` trait ```
