PHPackages                             jerowork/slim-route-attribute-provider - 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. jerowork/slim-route-attribute-provider

ActiveLibrary[API Development](/categories/api)

jerowork/slim-route-attribute-provider
======================================

Define Slim routes by PHP8 attributes

0.8.0(1y ago)1325[6 PRs](https://github.com/jerowork/slim-route-attribute-provider/pulls)MITPHPPHP ^8.1CI passing

Since Dec 7Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/jerowork/slim-route-attribute-provider)[ Packagist](https://packagist.org/packages/jerowork/slim-route-attribute-provider)[ RSS](/packages/jerowork-slim-route-attribute-provider/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (10)Versions (19)Used By (0)

slim-route-attribute-provider
=============================

[](#slim-route-attribute-provider)

[![Build Status](https://camo.githubusercontent.com/ee58d60f34d8a771c5f0bfb1df032685e87f514dc3eb2b37fe547a9ddc414780/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e742e7376673f75726c3d6874747073253341253246253246616374696f6e732d62616467652e6174726f782e6465762532466a65726f776f726b253246736c696d2d726f7574652d6174747269627574652d70726f766964657225324662616467652533467265662533446d61696e267374796c653d666c61742d737175617265)](https://github.com/jerowork/slim-route-attribute-provider/actions)[![Coverage Status](https://camo.githubusercontent.com/11d9cdf1601e68bec5af288c025b8dbacb8d140de3368b7c0721db81f7ddca76/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6a65726f776f726b2f736c696d2d726f7574652d6174747269627574652d70726f76696465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/jerowork/slim-route-attribute-provider/code-structure)[![Quality Score](https://camo.githubusercontent.com/e48b43192c8aa59e2b318c22bef355df9cd05b2255da70d045c7df803a8b188b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a65726f776f726b2f736c696d2d726f7574652d6174747269627574652d70726f76696465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/jerowork/slim-route-attribute-provider)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/63ee42c0409fbc5acdf8cca1afc89066965197a508520cf20fdc82f065060ad1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a65726f776f726b2f736c696d2d726f7574652d6174747269627574652d70726f76696465722e7376673f7374796c653d666c61742d73717561726526696e636c7564655f70726572656c6561736573)](https://packagist.org/packages/jerowork/slim-route-attribute-provider)[![PHP Version](https://camo.githubusercontent.com/3389172d235ce9321db25d1d256dfc51b1743da9b6d487179b04b93eedf7b05b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312b2d3838393242462e7376673f7374796c653d666c61742d737175617265)](http://www.php.net)

Define [Slim](https://www.slimframework.com) routes by PHP8 attributes.

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

[](#installation)

Install via [Composer](https://getcomposer.org):

```
$ composer require jerowork/slim-route-attribute-provider
```

Configuration
-------------

[](#configuration)

Instantiate `RouteAttributeConfigurator` somewhere close to the construction of your Slim application, e.g. in your front controller (or ideally register in your PSR-11 container).

Basic configuration:

```
use Jerowork\RouteAttributeProvider\RouteAttributeConfigurator;
use Jerowork\RouteAttributeProvider\Slim\SlimRouteAttributeProvider;
use Slim\Factory\AppFactory;

// Setup a (fictive) PSR-11 container and create Slim application
$container = new Container();
$app       = AppFactory::createFromContainer($container);

// ...

// Setup route attribute configuration
$routeConfigurator = new RouteAttributeConfigurator(
    SlimRouteAttributeProvider::createFromApp($app)
);

$routeConfigurator
    ->addDirectory(sprintf('%s/src/Infrastructure/Api/Http/Action', __DIR__))
    ->configure();

// ...

// Run Slim application
$app->run();
```

Extended configuration:

```
use Jerowork\FileClassReflector\FileFinder\RegexIterator\RegexIteratorFileFinder;
use Jerowork\FileClassReflector\NikicParser\NikicParserClassReflectorFactory;
use Jerowork\RouteAttributeProvider\RouteAttributeConfigurator;
use Jerowork\RouteAttributeProvider\Slim\SlimRouteAttributeProvider;
use PhpParser\NodeTraverser;
use PhpParser\ParserFactory;

// ...

// All parts of the configurator can be replaced with a custom implementation
$routeConfigurator = new RouteAttributeConfigurator(
    new SlimRouteAttributeProvider(
        $app->getRouteCollector(),
        $container
    ),
    new ClassReflectorRouteLoader(
        new NikicParserClassReflectorFactory(
            new RegexIteratorFileFinder(),
            (new ParserFactory())->create(ParserFactory::PREFER_PHP7),
            new NodeTraverser()
        )
    )
);

// Multiple directories can be defined
$routeConfigurator
    ->addDirectory(
        sprintf('%s/src/Infrastructure/Api/Http/Action', __DIR__),
        sprintf('%s/src/Other/Controller', __DIR__)
    )
    ->configure();

// ...
```

Usage
-----

[](#usage)

See [jerowork/route-attribute-provider](https://github.com/jerowork/route-attribute-provider#usage) for examples.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance66

Regular maintenance activity

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 64.6% 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 ~201 days

Recently: every ~337 days

Total

9

Last Release

379d ago

PHP version history (3 changes)0.1.0PHP ^8.0

0.6.0PHP ^8.0.2

0.7.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![jerowork](https://avatars.githubusercontent.com/u/4119451?v=4)](https://github.com/jerowork "jerowork (42 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (23 commits)")

---

Tags

attributesphp8routerslimrouterslimattributesphp8

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jerowork-slim-route-attribute-provider/health.svg)

```
[![Health](https://phpackages.com/badges/jerowork-slim-route-attribute-provider/health.svg)](https://phpackages.com/packages/jerowork-slim-route-attribute-provider)
```

###  Alternatives

[uderline/openapi-php-attributes

Automatically render your OpenApi 3 file describing your PHP API using attributes

2136.3k](/packages/uderline-openapi-php-attributes)[shahghasiadil/laravel-api-versioning

Elegant attribute-based API versioning solution for Laravel applications with built-in deprecation management and version inheritance

2913.6k](/packages/shahghasiadil-laravel-api-versioning)[jerowork/graphql-attribute-schema

Build your GraphQL schema for webonyx/graphql-php using PHP attributes instead of array-based configuration.

1727.1k](/packages/jerowork-graphql-attribute-schema)

PHPackages © 2026

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