PHPackages                             mpyw/null-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. mpyw/null-auth

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

mpyw/null-auth
==============

Null Guard for Laravel. Designed for Middleware-based authentication and testing.

v2.1.2(4mo ago)18112.3k↓28.9%4[1 issues](https://github.com/mpyw/null-auth/issues)MITPHPPHP ^8.2CI passing

Since Dec 10Pushed 4mo ago1 watchersCompare

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

READMEChangelog (9)Dependencies (7)Versions (12)Used By (0)

Null Auth [![Build Status](https://github.com/mpyw/null-auth/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mpyw/null-auth/actions) [![Coverage Status](https://camo.githubusercontent.com/961eae3e5ac9c548b8128e97b828fa405d409b0257e29af7c7682decd6ec4eb3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d7079772f6e756c6c2d617574682f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mpyw/null-auth?branch=master)
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#null-auth--)

[![](https://user-images.githubusercontent.com/1351893/70479968-e64e8e00-1b21-11ea-83c6-1d5e51f7e3e5.png)](https://user-images.githubusercontent.com/1351893/70479968-e64e8e00-1b21-11ea-83c6-1d5e51f7e3e5.png)

Null Guard for Laravel. Designed for Middleware-based authentication and testing.

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

[](#requirements)

- PHP: `^8.2`
- Laravel: `^11.0 || ^12.0`

Note

Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.

Installing
----------

[](#installing)

```
composer require mpyw/null-auth
```

Features
--------

[](#features)

### `NullAuthenticatable` family

[](#nullauthenticatable-family)

TraitIDPasswordRemember Token`GenericNullAuthenticatable`
`GenericStrictNullAuthenticatable`❗️❌❌`NullAuthenticatable`
`StrictNullAuthenticatable`✅❌❌`NoRememberTokenAuthenticatable`
`StrictNoRememberTokenAuthenticatable`✅✅❌- ❗️shows containing abstract methods.
- `Strict` traits throw `BadMethodCallException` on bad method calls.

### `NullGuard`

[](#nullguard)

- `NullGuard::user()` always returns Authenticatable already set by `NullGuard::setUser()`.
- `NullGuard::unsetUser()` can unset user.

### `NullUserProvider`

[](#nulluserprovider)

- All methods do nothing and always returns falsy value.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Edit your **`config/auth.php`**.

```
