PHPackages                             laravelclass/lara-auth - 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. laravelclass/lara-auth

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

laravelclass/lara-auth
======================

this package provides convenient way for laravel auth

121PHP

Since Mar 13Pushed 4y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Custom Laravel Authentication
=============================

[](#custom-laravel-authentication)

custom laravel authentication by one of mr rahmanian's classes' crew. if you want to contact mr ali rahmanian:

website: alirahmanian.com

instagram: ali.rahmanian.s.a

what's the point of this packages?
----------------------------------

[](#whats-the-point-of-this-packages)

we had so many limited with laravel starter kit authentication.so i decided to make an authentication package that removes many of laravel auth package limits.

Features
--------

[](#features)

- support multiple guard with diffrent configs
- support queue for notifications
- has hook system for define before and after logic
- support ajax request with an js abstract
- can change the response depend on state of package with hook
- can change all of response messages
- can define message for ajax request
- can define logic after ajax response
- can custom email's subject,from and.....
- can use custom email template or builtin email template
- can use you're own auth template

Deployment
----------

[](#deployment)

for install this package:

```
  composer require laravelclass/lara-auth
```

for serve config and ajax abstract:

```
  php artisan laraAuth:up
```

after serve the package,laraAuth.php and laraAuthAjax.js copied to configs and public directory

```
  configs/laraAuth.php
  public/laraAuthAjax.js
```

this package needs password\_resets table to complete the reset password; so dont for get to :

```
  php artisan migrate
```

change the confiuration
-----------------------

[](#change-the-confiuration)

in configs/laraAuth.php you can define you're configuration for sending email,auth,messages,attributes,rules,queue and...

how to use
----------

[](#how-to-use)

```
LaraAuth::makeAjax();

LaraAuth::before(function (){
     //you're logic.if you return the response, the package will not continue and server sends you're response!
});

LaraAuth::after(function ($status){
       //you're logic.if you return the response, the package will not continue and server sends you're response!
       // $status is the final state of the package core before sending the response;
});

     return LaraAuth::register('Admin','admins');
```

default guard is web and the default databaseModelName is User;

dont forget that you're model has to extends Authenticatable and use HasApiTokens, HasFactory, Notifiable;

if you want to send registration email,just implement MustVerifyEmail

methods available on LaraAuth Facade
------------------------------------

[](#methods-available-on-laraauth-facade)

```
LaravelClass\LaraAuth\Service\Facade\LaraAuth::before(\Closure $beforeClosure)

LaravelClass\LaraAuth\Service\Facade\LaraAuth::after(\Closure $afterClosure)

LaravelClass\LaraAuth\Service\Facade\LaraAuth::register($dbName = 'users' , $guard = 'web' , $extraData = null)

LaravelClass\LaraAuth\Service\Facade\LaraAuth::sendVerifyUserEmailNotification($guard= 'web', $dbName = 'User' , $notifiable = null)

LaravelClass\LaraAuth\Service\Facade\LaraAuth::canUserResetPassword($guard = 'web')

LaravelClass\LaraAuth\Service\Facade\LaraAuth::verifyEmailLink($guard = 'web')

LaravelClass\LaraAuth\Service\Facade\LaraAuth::verifyPasswordResetLink($guard = 'web' , $dbName = 'User')

LaravelClass\LaraAuth\Service\Facade\LaraAuth::login($guard = 'web')

LaravelClass\LaraAuth\Service\Facade\LaraAuth::logOut($guard = 'web')

LaravelClass\LaraAuth\Service\Facade\LaraAuth::sendResetPasswordNotification($guard = 'web' , $dbName = 'User')

LaravelClass\LaraAuth\Service\Facade\LaraAuth::makeAjax()
```

how to make hook system
-----------------------

[](#how-to-make-hook-system)

```
LaraAuth::before(function (){
     //you're logic.if you return the response, the package will not continue and server sends you're response!
});

LaraAuth::after(function ($status){
       //you're logic.if you return the response, the package will not continue and server sends you're response!
       // $status is the final state of the package core before sending the response;
});

 return LaraAuth::register('Admin','admins');
```

if you want to controll on before and after of package'core execution,you can use above methods; before() and after() methods accepts a closure that define youre logic.if you want to stop the execution of the package,you have to return an response object; in after() method,you're closure can accept the boolean the injected from the package core;this bool determine that if the operation was successful or not;

how to register,login and logout
--------------------------------

[](#how-to-registerlogin-and-logout)

```
return LaraAuth::login($guard = 'web')

return LaraAuth::logOut($guard = 'web')

return LaraAuth::register($dbName = 'users' , $guard = 'web' , $extraData = null)
```

all of the methods accepts $guard that determine the which guard you want to use from the gurad that you determined in auth.php config file

the default value for $guard and $dbname is web and User

if you want to determine the $dbName,you have to pass the Model Name like User

register() method accepts $extraData that you can pass an array of extra key value field that you want to insert to database in registration;

how to verify the email and reset the password
----------------------------------------------

[](#how-to-verify-the-email-and-reset-the-password)

```
return sendVerifyUserEmailNotification($guard= 'web', $dbName = 'User' , $notifiable = null)

return verifyEmailLink($guard = 'web')

return sendResetPasswordNotification($guard = 'web' , $dbName = 'User')

return verifyPasswordResetLink($guard = 'web' , $dbName = 'User')
```

if you want to send verify email or reset email,just return send...notificatoin method;

if you want to verify the email links,just return verify.... methods;

how to use package's middlewares
--------------------------------

[](#how-to-use-packages-middlewares)

```
->middleware('laraAuthEmail')  ==> for verify email

->middleware('laraAuthResetPassword')  ==> for password reset link
```

how to use queue for sending notification
-----------------------------------------

[](#how-to-use-queue-for-sending-notification)

```
'queue' => [
             'web' => [
                    'state' => true,
                    'delay' => 0,
                    'connection' => 'database',
                    'queue' => 'default'
                ],
                'admins' => [
                    'state' => false,
                    'delay' => 0,
                    'connection' => 'database',
                    'queue' => 'default'
                ],
```

you can find in laraAuth.php under the configs directory;

queue config is available for both of reset password notification and verifyEmailLink

you can determine it even for guards!!

dont forget to setup and start youre queue worker and queue database;

use ajax request
----------------

[](#use-ajax-request)

```
//put meta tag for csrf token in  tag

//put below codes after all of youre template tags

    const formInputs = ['email','password','password_confirmation'];
    const logic = function (laraAuthResponse){
        console.log(laraAuthResponse);
    }
    const obj = new LaraAuthAjax(logic,formInputs);

    //in youre action route in laravel,call this method before any of operation methods:

    LaraAuth::makeAjax();

    //then you can use one of package method like:

     return LaraAuth::login()
```

just put above cods into you're template;

laraAuthAjax class cunstructor take two arguments;the first argument is a closure that define you're logic after response comes from the server;you can define the parametr for the closure to get the json response! the second argument is the name of the inputs that you want to send to the server;if you dont have any,just let it go!

Authors
-------

[](#authors)

- [@blackhole](https://github.com/laravelclass)

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8707ee12fc18cd15a434503761933f066dddcdfc67948f89860a88ce91e2f8e0?d=identicon)[laravelclass](/maintainers/laravelclass)

---

Top Contributors

[![laravelclass](https://avatars.githubusercontent.com/u/100079075?v=4)](https://github.com/laravelclass "laravelclass (7 commits)")

### Embed Badge

![Health badge](/badges/laravelclass-lara-auth/health.svg)

```
[![Health](https://phpackages.com/badges/laravelclass-lara-auth/health.svg)](https://phpackages.com/packages/laravelclass-lara-auth)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
