PHPackages                             maksimovic/slim-oauth2-routes - 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. [API Development](/categories/api)
4. /
5. maksimovic/slim-oauth2-routes

ActiveLibrary[API Development](/categories/api)

maksimovic/slim-oauth2-routes
=============================

OAuth2 routes for use within a Slim Framework API

v4.0.2(3mo ago)02.0k1MITPHPPHP ^8.1CI passing

Since Jul 23Pushed 3mo agoCompare

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

READMEChangelog (2)Dependencies (6)Versions (22)Used By (1)

Chadicus\\Slim\\OAuth2\\Routes
==============================

[](#chadicusslimoauth2routes)

> **Fork Notice:** This is a maintained fork of the abandoned [`chadicus/slim-oauth2-routes`](https://github.com/chadicus/slim-oauth2-routes) package. Updated for PHP 8.1+ with fixes for PHP 8.4+ deprecations.

[OAuth2 Server](http://bshaffer.github.io/oauth2-server-php-docs/) route callbacks for use within a [Slim Framework](http://www.slimframework.com/) API.

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

[](#requirements)

PHP 8.1 or later.

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

[](#installation)

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

A Note on Using Views
---------------------

[](#a-note-on-using-views)

The `authorize` and `receive-code` routes require `view` objects. The given view object must implement a `render()` method such as the one found in [slim/php-view](https://github.com/slimphp/PHP-View).

Example Usage
-------------

[](#example-usage)

```
use Chadicus\Slim\OAuth2\Routes;
use OAuth2;
use OAuth2\GrantType;
use OAuth2\Storage;
use Slim;
use Slim\Views;

// Set up the OAuth2 Server
$storage = new Storage\Pdo(['dsn' => $dsn, 'username' => $username, 'password' => $password]);
$server = new OAuth2\Server($storage);
$server->addGrantType(new GrantType\AuthorizationCode($storage));
$server->addGrantType(new GrantType\ClientCredentials($storage));

// Set up the Slim Application
$app = new Slim\App([
    'view' => new Views\PhpRenderer('/path/to/maksimovic/slim-oauth2-routes/templates'),
]);

$container = $app->getContainer();

$app->map(['GET', 'POST'], Routes\Authorize::ROUTE, new Routes\Authorize($server, $container['view']))->setName('authorize');
$app->post(Routes\Token::ROUTE, new Routes\Token($server))->setName('token');
$app->map(['GET', 'POST'], Routes\ReceiveCode::ROUTE, new Routes\ReceiveCode($container['view']))->setName('receive-code');
$app->post(Routes\Revoke::ROUTE, new Routes\Revoke($server))->setName('revoke');

$app->run();
```

Authorize and The UserIdProvider
--------------------------------

[](#authorize-and-the-useridprovider)

Within the Authorization route, you can define a `UserIdProviderInterface` to extract the `user_id` from the incoming request. By default, the route will look in the `GET` query params.

```
use Chadicus\Slim\OAuth2\Routes\UserIdProviderInterface;
use Psr\Http\Message\ServerRequestInterface;

class ArgumentUserIdProvider implements UserIdProviderInterface
{
    public function getUserId(ServerRequestInterface $request, array $arguments = [])
    {
        return isset($arguments['user_id']) ? $arguments['user_id'] : null;
    }
}

$authorizeRoute = new Routes\Authorize($server, $view, 'authorize.phtml', new ArgumentUserIdProvider());
$app->map(['GET', 'POST'], Routes\Authorize::ROUTE, $authorizeRoute)->setName('authorize');
```

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

[](#development)

```
composer install
composer test
composer test:coverage
```

License
-------

[](#license)

MIT

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance81

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity81

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

Recently: every ~748 days

Total

21

Last Release

100d ago

Major Versions

v0.2.1 → v1.0.02016-02-05

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

v3.2.0 → v4.0.12026-03-13

v3.2.1 → v4.0.22026-03-18

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.2PHP ^5.6 || ^7.0

v3.2.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 (126 commits)")[![maksimovic](https://avatars.githubusercontent.com/u/1126226?v=4)](https://github.com/maksimovic "maksimovic (7 commits)")[![earllapura](https://avatars.githubusercontent.com/u/6143224?v=4)](https://github.com/earllapura "earllapura (2 commits)")[![jeffdrumgod](https://avatars.githubusercontent.com/u/504327?v=4)](https://github.com/jeffdrumgod "jeffdrumgod (2 commits)")

---

Tags

slimroutingoauth2

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/jsrouting-bundle

A pretty nice way to expose your Symfony routing to client applications.

1.5k55.3M259](/packages/friendsofsymfony-jsrouting-bundle)[phroute/phroute

Fast, fully featured restful request router for PHP

729470.6k29](/packages/phroute-phroute)[softonic/graphql-client

Softonic GraphQL client

1353.5M8](/packages/softonic-graphql-client)[stevenmaguire/yelp-php

A php client for consuming Yelp API

56411.9k](/packages/stevenmaguire-yelp-php)[chadicus/slim-oauth2-middleware

OAuth2 middleware for use within a Slim Framework API

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

Bridge components for PSR-7 and bshaffer's OAuth2 Server http messages.

18464.5k7](/packages/chadicus-slim-oauth2-http)

PHPackages © 2026

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