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

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

natilosir/auth
==============

A simple library for creating and managing users and authentication in PHP

1.0.0(1y ago)13MITPHP

Since Jan 23Pushed 1y ago1 watchersCompare

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

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

Auth-PHP
========

[](#auth-php)

A simple library for creating and managing users and authentication in PHP The Library provides a simple and effective way to handle user authentication in your PHP applications. It allows for user registration, login, logout, and session management using cookies. This library also hashes passwords for secure storage.

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

[](#installation)

You can install this package via Composer:

```
composer require natilosir/Auth
```

Usage
-----

[](#usage)

```
use natilosir\auth\auth;
```

Ensure that you have the required dependencies for cookie management and database operations.

Hashing Passwords The library provides a hashing function to securely hash passwords using MD5. You can call this function directly:

```
$passwordHash = hash($password);
```

Registering a User
------------------

[](#registering-a-user)

To register a new user, use the register method:

```
$response = Auth::register('user@example.com', 'securepassword');
```

This method returns an array indicating the status of the registration.

Logging In
----------

[](#logging-in)

To log in a user, use the attempt method:

```
$user = Auth::attempt('user@example.com', 'securepassword');
if ($user) {
    echo 'Login successful!';
} else {
    echo 'Login failed!';
}
```

Logging Out
-----------

[](#logging-out)

To log out the current user, simply call:

```
Auth::logout();
```

Checking User Status
--------------------

[](#checking-user-status)

To check if a user is logged in and retrieve their information:

```
$userInfo = Auth::check();
```

Getting All Users
-----------------

[](#getting-all-users)

To retrieve all registered users:

```
$allUsers = Auth::getAllUsers();
```

Retrieving User from Cookie
---------------------------

[](#retrieving-user-from-cookie)

To get the currently logged-in user from the cookie:

```
$currentUser = Auth::getUserFromCookie();
```

Getting User ID
---------------

[](#getting-user-id)

To retrieve the ID of the currently logged-in user:

```
$userId = Auth::id();
```

Functions
=========

[](#functions)

`hash($password)`Hashes the provided password using MD5 and returns a substring of the hash from the 5th to the 15th character.

`Auth::attempt($username, $password)`Attempts to log in a user with the provided username (email or username) and password.

`Auth::register($username, $password)`Registers a new user with the specified username (email or username) and password.

`Auth::logout()`Logs out the current user by deleting the user cookie.

`Auth::check()`Checks the authentication status of the user and returns user information.

`Auth::getUserFromCookie()`Retrieves the username from the cookie.

`Auth::getAllUsers()`Returns an array of all registered users.

`Auth::user()`Returns the currently logged-in user.

`Auth::id()`Returns the ID of the currently logged-in user.

`Auth::login($user)`Logs in a user by setting the user cookie.

`Auth::loginUsingId($id)`Logs in a user using their ID.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance42

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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

Unknown

Total

1

Last Release

481d ago

### Community

Maintainers

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

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

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

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