PHPackages                             dszczer/minion - 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. [Framework](/categories/framework)
4. /
5. dszczer/minion

AbandonedArchivedLibrary[Framework](/categories/framework)

dszczer/minion
==============

Powerful wrapper extending Silex, merging simplicity of Silex and usability of Symfony 2

v1.0.0(10y ago)052MITPHPPHP &gt;=5.6 || ~7.0

Since Jan 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/dszczer/Minion)[ Packagist](https://packagist.org/packages/dszczer/minion)[ RSS](/packages/dszczer-minion/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (9)Versions (2)Used By (0)

Minion - Silex framework wrapper
================================

[](#minion---silex-framework-wrapper)

> Powerful wrapper extending Silex, merging simplicity of Silex and usability of Symfony 2.

Table of Contents
-----------------

[](#table-of-contents)

1. [Main features](#main-features)
2. [Installation](#installation)
3. [Usage](#usage)
    - [Project directory tree](#project-directory-tree)
    - [Custom project directory structure](#custom-project-directory-structure)
    - [Bootstrap](#bootstrap)
    - [Application environments](#applicaiton-environments)
    - [Initial configuration](#initial-configuration)
    - [Routing](#routing)
    - [Services](#services)
    - [Error pages](#error-pages)
    - [Console](#console)
4. [API Documentation](#api-documentation)

Main features
-------------

[](#main-features)

- Silex basic features ([see more](http://silex.sensiolabs.org/documentation "Silex documentation"))
- Propel 2.x integration
- Twig 2.x integration
- More flexible services
- Controller classes with handy helpers
- Command line support

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

[](#installation)

> *NOTE: Minion require PHP version 5.6.x or greater*.

#### Using Composer

[](#using-composer)

Type in console `composer require dszczer/minion`.

Usage
-----

[](#usage)

#### Project directory tree

[](#project-directory-tree)

##### Legend:

[](#legend)

- *\* required*
- *\[name\] directory*

```
. (root directory)
+-- [app]*
|   +-- config.yml*
|   +-- parameters.yml*
|   +-- routing.yml*
|
+-- [bin] (autogenerated by Composer)
|
+-- [src]* (project source code)
|   +-- [Controller]*
|   +-- [Resources] (required if using Twig)
|       +-- [views]*
|
+-- [var]*
|   +-- [cache] (must have write permission)
|   +-- [log] (must have write permission)
|
+-- [vendor]* (Composer dependencies)
|
+-- [web]* (public access directory - server document root)
    +-- assets (any directory structure)
    +-- index.php (entry point)

```

#### Custom project directory structure

[](#custom-project-directory-structure)

If you want to use other directory structure or you have no choice (e.g. shared hosting), you can define custom paths as third `__construct` Application's method:

- string `rootDir` - project root directory
- string `packageDir` - Minion vendor's directory root
- string `configPath` - configuration files path, default is `/app/`
- string `propelConfigPath` - Propel sensitive-data and project-specific `propel.php` configuration file path; ignored if option `minion.usePropel` is `false`

#### Bootstrap

[](#bootstrap)

All you need to bootstrap Minion is include Composer autoloader, provide application namespace *(not required, but recommended)*, instantiate `Minion\Application` and call `run()` method on it.

```
// web/index.php

require_once __DIR__ . '/../vendor/autoload.php';

// it is recommended to provide ./src/ namespace, but Minion will try to guess this value
$namespace = 'Project\\';

$app = new Minion\Application($namespace, ['debug' => false, 'environment' => 'prod']);
$app->run();
```

You will need to configure your server to point `./web` directory as the **only one** with public access, and `index.php` as directory index. Look [here](http://silex.sensiolabs.org/doc/web_servers.html) for more information.

##### Application environments

[](#application-environments)

Avaliable environments:

- `prod` **production** - production environment which should be used in production server
- `test` **testing** - testing environment which disable handling error exceptions

##### Initial configuration

[](#initial-configuration)

You can pass several options into second `__construct()` argument Application's method:

- bool `debug` - debugging mode, true to enable, false to disable
- string `environment` `['prod'|'test']` - working application's environment
- bool `minion.usePropel` - true to use Propel ORM, false to don't
- bool `minion.useTwig` - true to use Twig templating, false to don't

#### Routing

[](#routing)

##### Routing map

[](#routing-map)

Routing map file is based on [Symfony 2 routing files](http://symfony.com/doc/2.8/book/routing.html#basic-route-configuration) component.

```
# app/routing.yml

homepage:
    path: /
    defaults: { _controller: "DefaultController::indexAction" }

# ...
```

##### Controllers

[](#controllers)

Minion provides helpful controller basic class. To extend this class and use actions, write your controller like this:

```
// src/Controller/DefaultController.php

namespace Project\Controller;

use Minion\Controller;
use Minion\Application;
use Symfony\HttpFoundation\Request;
// ...

class DefaultController extends Controller
{
    public function indexAction(Request $request, Application $app)
    {
        // ...

        // if you're using Twig, path is relative to src/Resources/views/
        return $this->render('index.html.twig');

        // if you're not using Twig, path is relative to src/
        return $this->render('template_index.html.php');
    }
}
```

**IMPORTANT:** action shall **always** return an `Symfony\HttpFoundation\Response` object *(exactly like in Symfony 2)*. For more information about avaliable methods, look into [API documentation](http://dszczer.github.io/Minion/class-Minion.Controller.html).

#### Services

[](#services)

Services in Minion are something between Silex and Symfony 2. They are expandable, flexible and easy in use.

##### Writing own service

[](#writing-own-service)

First, you must write a new Service class:

```
// src/Service/MyService.php

namespace Project\Service;

class MyService
{
    public function foo()
    {
        return 'bar';
    }
}
```

Then, you should write provider class:

```
// src/Service/CustomServiceProvider.php

namespace Project\Service;

use \Minion\Service\ServiceProvider;
use \Silex\Application as SilexApp;

class CustomServiceProvider extends ServiceProvider
{
    public function register(SilexApp $app)
    {
        $config = $this->getServiceConfig();
        $app[ $config->getId() ] = $app->share(function(SilexApp $app) {
            return new MyService();
        });
    }

    public function boot(SilexApp $app) {}
}
```

`CustomServiceProvider` **shall** extend `Minion\Service\ServiceProvider` basic class or implement `Minion\Service\ServiceProviderInterface` interface. Of course, instead of sharing a new service, you are fully able to extend an exisitng one. Example below is extending Twig with `Twig_Extension` class:

```
// src/Service/CustomServiceProvider.php

namespace Project\Service;

use \Minion\Service\ServiceProvider;
use \Silex\Application as SilexApp;

class CustomServiceProvider extends ServiceProvider
{
    public function register(SilexApp $app)
    {
        $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig, SilexApp $app) {
            $class = $this->getServiceConfig()->getOption('twig.extension.class'); // is \Project\Util\MyTwigExtension
            $twig->addExtension(new $class);

            return $twig;
        }));
    }

    public function boot(SilexApp $app) {}
}
```

Finally, you can define your custom service in `app/config.yml` file:

```
# app/config.yml

services:
    my_custom_service_id: # unique service id
        class: "Project\\Service\\CustomServiceProvider" # service provider's fully qualified class name
        options:  # options accesible inside service provider
            twig.extension.class: "\\Project\\Util\\MyTwigExtension"
```

And Voile'a! You have registered your new service. You can use it for e.g. inside controller's action:

```
// ...
class DefaultController extends Controller
{
    public function defaultAction(Request $request, Application $app) {
        $myServiceName = $app['my_custom_service']->foo(); // should return 'bar'
    }
}
```

> *HINT*: Minion has it's own Twig extension service provider expander, so you don't have to write your own one. [Read more below](#service-tags).

##### Service configuration

[](#service-configuration)

Inside service provider's `register` method you have full access to service configuration, thanks to `Minion\Service\ServiceConfigInterface`:

```
// ...

class CustomServiceProvider extends ServiceProvider
{
    public function register(SilexApp $app)
    {
        $serviceConfiguration = $this->getServiceConfig();
    }

    // ...
}
```

##### Service tags

[](#service-tags)

Service tags are marks for Minion to use build-in service provider and are special case use. Avaliable tags:

- `twig.extension`

**Tag `twig.extension`** is defined in `app/config.yml` like below:

```
# app/config.yml

services:
    my_custom_twig_extension_id:
        class: "\\Project\\Twig\\MyCustomTwigExtension"
        #options:   # optional
        tags:
            - twig.extension
```

##### Build-in Twig extensions, ready to use

[](#build-in-twig-extensions-ready-to-use)

List of build-in twig extensions:

- `AssetExtension` - assets for web use, helps to define web side or server side related paths
- `MiscExtension` - some miscellaneous functions thay may be useful
- `UrlExtension` - generating links in templates with this is easy For more information about avaliable methods, see [API documentation](http://dszczer.github.io/Minion/class-Minion.Twig.AssetExtension.html).

#### Error pages

[](#error-pages)

Minion allows you to customize error pages for `403`, `404` and `500` HTTP status codes. Inside your template scope *only* thrown exception would be avaliable under (Twig) `exception` or (PHP) `$exception` variable name. Template file can be standalone or extending other template file.

##### Twig template

[](#twig-template)

Place Twig template under `src/Resources/views/Static/.html.twig` name, where `` is a status code generated by Application.

##### PHP template

[](#php-template)

If you are not using Twig, place your PHP template under `src/Static/.html.php` name, where `` is a status code generated by Application.

#### Console

[](#console)

Minion provides easy in use CLI mode. All project specific commands should be stored in `src/Command` directory and should extend `Knp\Command\Command` class. More about Knp Command avaliable here.

##### Naming conventions

[](#naming-conventions)

Command file **must** have name with suffix `Command.php`. Class name also **must** contain `Command` suffix. Files that do not fulfill those conditions are ignored. **Example command:**

```
// src/Command/ProjectCommand.php

namespace Project\Command;

use Knp\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ProjectCommand extends Command
{
    // Configure command
    protected function configure() {
        $this
            ->setName('project')
            ->setDescription('project command')
        ;
    }

    // Execute command
    public function execute(InputInterface $input, OutputInterface $output) {
        $output->write('project command in practice');
    }
}
```

##### Bootstrap

[](#bootstrap-1)

Minion already has bootstrap file for CLI mode, so it should be accessible in your `bin` directory, after installing dependencies with Composer.

##### Usage

[](#usage-1)

To run Minion in CLI mode, go to your project directory (bash, windows command, etc.) and type `bin/console command:name`.

> Minion provides autoloader for Propel commands. If you want to use propel commands, type in project root directory `bin/console propel:namespace:command`, for e.g. `bin/console propel:model:build`, or just use *aliases* `bin/console build`.

##### Registering

[](#registering)

Minion has command autoloader, so you just need to place `Command` class in the right directory `src/Command`. That's all! Of course, you can load commands from anywhere, just call `$app->loadCommands($path, $prefix)` before `$app->run()`. Required `$path` argument is an **absolute** path to directory containing command files. Optional `$prefix` argument is a namespace for them. So, if you enter prefix, your command for e.g. `command:exec` will be avaliable under `prefix:command:exec`.

API Documentation
-----------------

[](#api-documentation)

[Click here](http://dszczer.github.io/-OUTDATED-Minion/) to see detailed API documentation.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3805d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15196453?v=4)[Damian Szczerbiński](/maintainers/dszczer)[@dszczer](https://github.com/dszczer)

---

Top Contributors

[![dszczer](https://avatars.githubusercontent.com/u/15196453?v=4)](https://github.com/dszczer "dszczer (13 commits)")

---

Tags

silexminionsilex fatminion frameworksymfony lightsymfony2 lightsymfony 2 light

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dszczer-minion/health.svg)

```
[![Health](https://phpackages.com/badges/dszczer-minion/health.svg)](https://phpackages.com/packages/dszczer-minion)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M518](/packages/shopware-core)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M462](/packages/pimcore-pimcore)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9317.2k55](/packages/open-dxp-opendxp)

PHPackages © 2026

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