PHPackages                             maksimovic/slim-oauth2-middleware - 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. maksimovic/slim-oauth2-middleware

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

maksimovic/slim-oauth2-middleware
=================================

OAuth2 middleware for use within a Slim Framework API

5.0.0(2mo ago)02.0k1MITPHPPHP ^8.1CI passing

Since Jul 23Pushed 2mo agoCompare

[ Source](https://github.com/maksimovic/slim-oauth2-middleware)[ Packagist](https://packagist.org/packages/maksimovic/slim-oauth2-middleware)[ RSS](/packages/maksimovic-slim-oauth2-middleware/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (18)Versions (25)Used By (1)

Chadicus\\Slim\\OAuth2\\Middleware
==================================

[](#chadicusslimoauth2middleware)

> **Fork Notice:** This is a maintained fork of the abandoned [`chadicus/slim-oauth2-middleware`](https://github.com/chadicus/slim-oauth2-middleware) package. Updated for PHP 8.1+ and PSR-15.

[![License](https://camo.githubusercontent.com/734508b359fe427e61876360db5d0c09f026c3a81629ce7688d94f2a31989e01/68747470733a2f2f706f7365722e707567782e6f72672f6d616b73696d6f7669632f736c696d2d6f61757468322d6d6964646c65776172652f6c6963656e7365)](https://packagist.org/packages/maksimovic/slim-oauth2-middleware)

PSR-15 middleware for using [OAuth2 Server](http://bshaffer.github.io/oauth2-server-php-docs/) within any PSR-15 compatible framework, including [Slim 4](http://www.slimframework.com/).

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

[](#requirements)

PHP 8.1 or later.

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

[](#installation)

```
composer require maksimovic/slim-oauth2-middleware
```

Example usage
-------------

[](#example-usage)

```
use Chadicus\Slim\OAuth2\Middleware\Authorization;
use OAuth2;
use OAuth2\Storage;
use OAuth2\GrantType;

$storage = new Storage\Memory([
    'client_credentials' => [
        'administrator' => ['client_id' => 'administrator', 'client_secret' => 'password', 'scope' => 'superUser'],
    ],
]);

$server = new OAuth2\Server(
    $storage,
    ['access_lifetime' => 3600],
    [new GrantType\ClientCredentials($storage)]
);

$auth = new Authorization($server, $container);

// Slim 4
$app->get('/foos', $handler)->add($auth);
$app->post('/foos', $handler)->add($auth->withRequiredScope(['superUser']));
```

`$container` must be either an `ArrayAccess` or expose a `set($key, $value)` method (e.g. PHP-DI). The decoded access token is stored under the `'token'` key on success and added to the request as the `oauth2-token` attribute.

Development
-----------

[](#development)

```
composer install
composer test
composer test:coverage
composer cs-check
```

License
-------

[](#license)

MIT

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance88

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 92% 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 ~171 days

Recently: every ~11 days

Total

24

Last Release

60d ago

Major Versions

v0.2.3 → v1.0.02016-02-04

v1.x-dev → v3.0.02016-05-22

v3.4.0 → v4.0.12026-03-13

v3.4.1 → v4.0.22026-03-18

v4.0.2 → v5.x-dev2026-04-28

PHP version history (6 changes)v0.1.0PHP ~5.4 || ~7.0

v1.0.0PHP ~5.5 || ~7.0

v3.0.0PHP ~5.6 || ~7.0

v3.1.1PHP ^5.6 || ^7.0

v3.3.0PHP ^5.6 || ^7.0 || ^8.0

v4.0.1PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![chadicus](https://avatars.githubusercontent.com/u/1182337?v=4)](https://github.com/chadicus "chadicus (127 commits)")[![maksimovic](https://avatars.githubusercontent.com/u/1126226?v=4)](https://github.com/maksimovic "maksimovic (9 commits)")[![markfrydrych](https://avatars.githubusercontent.com/u/20677808?v=4)](https://github.com/markfrydrych "markfrydrych (1 commits)")[![soren121](https://avatars.githubusercontent.com/u/295939?v=4)](https://github.com/soren121 "soren121 (1 commits)")

---

Tags

middlewareslimoauth2

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/maksimovic-slim-oauth2-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/maksimovic-slim-oauth2-middleware/health.svg)](https://phpackages.com/packages/maksimovic-slim-oauth2-middleware)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.7k143.0M272](/packages/league-oauth2-server)[google/auth

Google Auth Library for PHP

1.4k286.7M205](/packages/google-auth)[chadicus/slim-oauth2-middleware

OAuth2 middleware for use within a Slim Framework API

47420.7k1](/packages/chadicus-slim-oauth2-middleware)[cakephp/authentication

Authentication plugin for CakePHP

1143.9M95](/packages/cakephp-authentication)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28545.4k3](/packages/mezzio-mezzio-authentication-oauth2)

PHPackages © 2026

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