PHPackages                             cofa/laravel-authentication-flow - 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. cofa/laravel-authentication-flow

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

cofa/laravel-authentication-flow
================================

Simple authentication flow with validation and flexibility of credentials so you can use phone, email whatever you want .

v1.0.4(9mo ago)0607MITPHPPHP ^8.2

Since Aug 12Pushed 9mo agoCompare

[ Source](https://github.com/Cofa12/laravel-authentication-flow)[ Packagist](https://packagist.org/packages/cofa/laravel-authentication-flow)[ RSS](/packages/cofa-laravel-authentication-flow/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

Laravel Authentication Flow
===========================

[](#laravel-authentication-flow)

A simple and flexible authentication package for Laravel applications with JWT support. This package provides a complete authentication flow with login, registration, token refresh, and logout functionality.

Features
--------

[](#features)

- JWT-based authentication
- Login and registration endpoints
- Token refresh mechanism
- Secure logout with token blacklisting
- Configurable token expiration times
- Flexible credential validation

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 12.x
- Tymon JWT Auth package

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

[](#installation)

### 1. Install the package via Composer

[](#1-install-the-package-via-composer)

```
composer require cofa/laravel-authentication-flow
```

### 2. Configuration (Optional)

[](#2-configuration-optional)

The package comes with default configuration that will be automatically merged. If you want to customize the settings, publish the configuration file:

```
php artisan vendor:publish --provider="Cofa\LaravelAuthenticationFlow\ApiAuthServiceProvider" --tag="config"
```

This will create a `config/apiauth.php` file in your application that you can modify.

JWT Configuration
-----------------

[](#jwt-configuration)

### 1. JWT Setup

[](#1-jwt-setup)

The `tymon/jwt-auth` package is automatically installed as a dependency. Laravel will handle the provider registration automatically.

### 2. Generate JWT Secret Key

[](#2-generate-jwt-secret-key)

Generate a secret key for JWT:

```
php artisan jwt:secret
```

This will update your `.env` file with a `JWT_SECRET` value.

### 3. Configure Auth Guard

[](#3-configure-auth-guard)

Update your `config/auth.php` file to use the JWT guard:

```
'guards' => [
    // ...
    'api' => [
        'driver' => 'jwt',
        'provider' => 'users',
    ],
],
```

### 4. Update User Model

[](#4-update-user-model)

Update your User model to implement the JWT interface:

```
