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

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

marcosdipaolo/auth
==================

An PHP Authentication Package

1.0.6(2y ago)053MITPHPPHP &gt;=8.2

Since Jan 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/marcosdipaolo/auth)[ Packagist](https://packagist.org/packages/marcosdipaolo/auth)[ RSS](/packages/marcosdipaolo-auth/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (7)Dependencies (2)Versions (8)Used By (0)

Auth
====

[](#auth)

A basic PHP Authentication Package
----------------------------------

[](#a-basic-php-authentication-package)

The `Auth` constructor receives as a unique argument a `PDO` instance connected to your app's database.
This connection is necessary to check credentials and register users. The rest of the operations can be performed without passing anything, like logging in or logging out a user, checking if there's a user logged in, or getting the logged user.

The login and logout method just puts or remove the user in the `user` session's key. In order to do so `Auth` makes use of the `marcosdipaolo/session` package.

### Usage

[](#usage)

#### Configuration

[](#configuration)

```
/** @var PDO $pdoInstance */
$auth = new MDP\Auth\Auth($pdoInstance);

// Setting the users table name
// The table the Auth package is going to interact with:
$auth->setUsersTableName('members'); // default: 'users'

// Setting the table fields the package should manage
$auth->setEmailField('email_address'); // default: 'email'
$auth->setPasswordField('pass'); // default: 'password'
$auth->setUsernameField('alias'); // default: 'username'

// You can do it in one time with the setUsersTableFields method
$auth->setUsersTableFields([
    'usernameField' => 'username',
    'passwordField' => 'password',
    'emailField' => 'email'
]); // boolean, true if at least one field was set

// Set the column that is going to be evaluated for logging in
$auth->setLoginField('email');  // default: 'email'
```

#### Login and register

[](#login-and-register)

In order to log a user in, you must use the login method passing as an argument an instance of a user, whose class should be implementing the `\MDP\Auth\Autheticatable` interface.

```
/** @var \MDP\Auth\Auth $auth */// boolean;v

/** @var MDP\Auth\Authenticatable $user */
$auth->login($user); // logs in a user
```

Here checking credentials, loggin out, checking if there's a logged user, getting the logged user and registering.

```
/** @var \MDP\Auth\Auth $auth */

// check credentials
$auth->check('yourField', 'youPassword');

// Register a user
$auth->register('john_doe', 'john@doe.com', 'myPassword'); // bool (true if successful)

$auth->logout(); // logs out whoever was logged in

// Checks if there's someone logged in
$auth->isUserLoggedIn(); // bool

// Returns the logged user
$auth->user(); // MDP\Auth\Authenticatable logged user | null
```

#### Helper `auth()`

[](#helper-auth)

The `auth()` helper return an instance of the Auth class.
Since many operations do not require a connection to the db, you are not required of passing the instance of the `PDO` class as an argument.
If you need to perform operations that requires a db connection, like `register`, or `check` you need to pass the `PDO` instance `auth($pdo)`.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 53.3% 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.

###  Release Activity

Cadence

Every ~190 days

Recently: every ~285 days

Total

7

Last Release

809d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.2

1.0.6PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22824656?v=4)[marcosdipaolo](/maintainers/marcosdipaolo)[@marcosdipaolo](https://github.com/marcosdipaolo)

---

Top Contributors

[![marcosdipaoloSV](https://avatars.githubusercontent.com/u/76181292?v=4)](https://github.com/marcosdipaoloSV "marcosdipaoloSV (8 commits)")[![marcosdipaolo](https://avatars.githubusercontent.com/u/22824656?v=4)](https://github.com/marcosdipaolo "marcosdipaolo (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/marcosdipaolo-auth/health.svg)](https://phpackages.com/packages/marcosdipaolo-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)
