PHPackages                             dakujem/slim-factory - 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. dakujem/slim-factory

ActiveLibrary

dakujem/slim-factory
====================

A tiny tool to help you bootstrap a Slim v4 app.

1.1(1y ago)05.1kUnlicensePHPPHP ^8.1CI passing

Since Nov 2Pushed 4mo ago1 watchersCompare

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

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

Slim factory helper for Slim v4
===============================

[](#slim-factory-helper-for-slim-v4)

[![PHP from Packagist](https://camo.githubusercontent.com/dc94dbdd295b194fdd2274ce9077eefc5d96bf9933e58e10f7594f3a729abf07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616b756a656d2f736c696d2d666163746f7279)](https://camo.githubusercontent.com/dc94dbdd295b194fdd2274ce9077eefc5d96bf9933e58e10f7594f3a729abf07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616b756a656d2f736c696d2d666163746f7279)[![Test Suite](https://github.com/dakujem/slim-factory/actions/workflows/php-test.yml/badge.svg)](https://github.com/dakujem/slim-factory/actions/workflows/php-test.yml)[![Coverage Status](https://camo.githubusercontent.com/90ba3c5b8c3379679da0b276d9b16b19cd59e707d20ba3ba44285f2d89510bc0/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f64616b756a656d2f736c696d2d666163746f72792f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/dakujem/slim-factory?branch=main)

> 💿 `composer require dakujem/slim-factory`

Usage
-----

[](#usage)

```
use Dakujem\Slim\SlimFactory;
```

Build an App instance, optionally provide decorators and/or a container for the App instance:

```
$app = SlimFactory::build();
$app = SlimFactory::build($decorators);
$app = SlimFactory::build($decorators, $container);
```

Or, build an App instance using core services from a container, with optional decorators:

```
$app = SlimFactory::buildFromContainer($container);
$app = SlimFactory::buildFromContainer($container, $decorators);
```

In case you already have an instance od Slim `App`, your decorators can be used to decorate it:

```
$app = Slim\Factory\AppFactory::create( ... );
SlimFactory::decorate($app, $decorators);
```

A **decorator** may be:

- an instance of `AppDecoratorInterface` implementation
- a string name of such a class
- a callable provider of such an instance \*\*
- a callable that directly decorates the slim app instance \*\*

```
class MiddlewareDecorator implements AppDecoratorInterface
{
    public function decorate(App $slim): void
    {
        $slim->addRoutingMiddleware();
        $slim->addBodyParsingMiddleware();
        $slim->addErrorMiddleware();
    }
}

// The following 4 decorators are equivalent:
$decorators = [
    new MiddlewareDecorator(),          // a decorator instance
    MiddlewareDecorator::class,         // a class name
    fn() => new MiddlewareDecorator(),  // a decorator provider
    function(App $slim): void {         // a callable decorator
        $slim->addRoutingMiddleware();
        $slim->addBodyParsingMiddleware();
        $slim->addErrorMiddleware();
    }
];
```

> \*\* Note
>
> If a callable is used as a decorator, it is always invoked, regardless of its signature.
>
> If the callable returns an instance of a decorator (an implementation of `AppDecoratorInterface`), the returned decorator is immediately applied too.
>
> The callables receive the instance of the App being decorated as the first argument, which is the same signature as the one of `AppDecoratorInterface::decorate` method.

Testing
-------

[](#testing)

Run unit tests using the following command:

`$` `composer test`

Contributing
------------

[](#contributing)

Ideas, feature requests and other contribution is welcome. Please send a PR or create an issue.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance61

Regular maintenance activity

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~521 days

Total

4

Last Release

452d ago

PHP version history (2 changes)1.0.0-alphaPHP ^7.2 || ^8.0

1.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/0bd7fa945013e9c0dcd65693575276bf5fcb9b9de13e1123e9f2c4a0a4c0fb6b?d=identicon)[dakujem](/maintainers/dakujem)

---

Top Contributors

[![dakujem](https://avatars.githubusercontent.com/u/443067?v=4)](https://github.com/dakujem "dakujem (17 commits)")

### Embed Badge

![Health badge](/badges/dakujem-slim-factory/health.svg)

```
[![Health](https://phpackages.com/badges/dakujem-slim-factory/health.svg)](https://phpackages.com/packages/dakujem-slim-factory)
```

###  Alternatives

[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[api-platform/state

API Platform state interfaces

223.4M57](/packages/api-platform-state)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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