PHPackages                             tunaaoguzhann/php-auth-api - 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. tunaaoguzhann/php-auth-api

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

tunaaoguzhann/php-auth-api
==========================

Modern PHP Authentication API with JWT and Redis

06PHP

Since Jan 2Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Auth API
============

[](#php-auth-api)

Modern PHP Authentication API with JWT, Redis, and Request/Response handling.

Features
--------

[](#features)

- JWT based authentication
- Redis token management
- MySQL database integration
- Modern Request/Response handling
- Router with middleware support
- Easy integration

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

[](#requirements)

- PHP 8.1+
- MySQL/MariaDB
- Redis
- Composer

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

[](#installation)

1. Install via Composer:

```
composer require tunaaoguzhann/php-auth-api
```

2. Create `.env` file in your project root:

```
# Application
APP_DEBUG=true

# Database
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=auth_api
DB_USERNAME=your_db_username
DB_PASSWORD=your_db_password

# Redis
REDIS_HOST=localhost
REDIS_PORT=6379

# JWT Settings
JWT_SECRET=your-secret-key-here
JWT_EXPIRES_IN=3600
```

3. Create the users table in your database:

```
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    email VARCHAR(255) UNIQUE NOT NULL,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

Create an `index.php` file in your project root:

```
