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 today

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

23

—

LowBetter than 26% of packages

Maintenance39

Infrequent updates — may be unmaintained

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

527d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/182812192?v=4)[MMD](/maintainers/natilosir)[@natilosir](https://github.com/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

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

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