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

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

objectiveweb/auth
=================

Authentication library

v0.1.13(9y ago)33701[1 PRs](https://github.com/objectiveweb/auth/pulls)MITPHPPHP &gt;=5.3.0

Since Feb 17Pushed 1mo ago2 watchersCompare

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

READMEChangelogDependencies (1)Versions (18)Used By (0)

Auth [![Build Status](https://camo.githubusercontent.com/f63415f9d94be682a57da4039cfc486ab8a0b1a78af7d68afdb5793457f61a1f/68747470733a2f2f7472617669732d63692e6f72672f6f626a6563746976657765622f617574682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/objectiveweb/auth)
=======================================================================================================================================================================================================================================================================================

[](#auth-)

Authentication Library

Setup
-----

[](#setup)

Setup the auth dependency on your project's composer.json, then run `composer update`

```
   "require": {
       "objectiveweb/auth": "~0.1"
   }

```

### Auth initialization

[](#auth-initialization)

Create a new $auth instance, passing the appropriate parameters

```
// Auth depends on PDO
$pdo = new PDO($dsn);

$auth = new Auth($pdo, [
    'session_key' => 'ow_auth',
    'table' => 'ow_auth',
    'id' => 'id',
    'username' => 'username',
    'password' => 'password',
    'token' => NULL,
    'created' => NULL,
    'last_login' => NULL
]);

```

#### Parameters

[](#parameters)

- 'session\_key'

    Key used for $\_SESSION storage, defaults to 'ow\_auth'
- 'table'

    Database table which stores users, defaults to 'ow\_auth'
- 'id'

    Primary key of the user table, defaults to 'id'
- 'username'

    Username field on the user table, defaults to 'username'
- 'password'

    Password field on the user table, defaults to 'password',
- 'token'

    Optional CHAR(32) field to store a random token
- 'created'

    Optional DATETIME field to store the accounts creation date
- 'last\_login'

    Optional DATETIME field to store the last successful login date

Usage
-----

[](#usage)

```
# register user
try {
    $user = $auth->register('username', 'password');
}
catch(\Exception $ex) {
    printf('DB Error creating user: %s', $ex->getMessage());
}

# login user
try {
    $user = $auth->login('username', 'password');
}
catch(PasswordMismatchException $ex) {
    printf("Password mismatch");
}
catch(UserException $ex) {
    printf("Error logging in: %s", $ex->getMessage());
}

# check if the user is logged in
if($auth->check()) {
    // user is logged in
}
else {
    // user is not logged in
};

# retrieve the current user from the session
try {
    $user = $auth->user();
}
catch(UserException $ex) {
    printf("User not logged in");
}

# logout user
$auth->logout();

```

### Store additional data when registering a user

[](#store-additional-data-when-registering-a-user)

```
$user = $auth->register('username', 'password', [
    'email' => 'someone@somewhere',
    'displayName' => 'Test User'
]);

```

### Generating a password reset token

[](#generating-a-password-reset-token)

When the `token` parameter is enabled in initialization

```
$token = $auth->update_token($username);

// send $token to user, then later
try {
    $auth->passwd_reset($token, $new_password);
}
catch(UserException $ex) {
    printf('Invalid token provided');
}

```

### Updating user data

[](#updating-user-data)

```
$auth->update($username, [ 'email' => 'new@email.com' ]);

```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance59

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

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 ~42 days

Recently: every ~76 days

Total

14

Last Release

3566d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca62337abc932b77ca92aed231e2af00f4504eab5b7425dcb2ae910a43e3af59?d=identicon)[guigouz](/maintainers/guigouz)

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[illuminate/auth

The Illuminate Auth package.

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

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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