PHPackages                             nyholm/super-slim - 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. nyholm/super-slim

ActiveProject

nyholm/super-slim
=================

A quick and extendable framework which delivers content blazing fast

0.1.0(7y ago)38295MITPHPPHP ^7.2

Since Feb 23Pushed 6y ago3 watchersCompare

[ Source](https://github.com/Nyholm/SuperSlim)[ Packagist](https://packagist.org/packages/nyholm/super-slim)[ RSS](/packages/nyholm-super-slim/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Nyholm's SuperSlim framework
============================

[](#nyholms-superslim-framework)

The quickest and best framework you can start building on.

```
composer create-project nyholm/super-slim foobar-microservice
```

The idea
--------

[](#the-idea)

The idea of this framework is to give you a good foundation to start building your application. **No file is sacred** in this framework. It is *you* as a developer that are responsible for code and the dependencies you use.

If you eventually outgrow this framework, just replace `Kernel.php` with Symfony's Kernel and you are running a Symfony 4 application.

Performance
-----------

[](#performance)

Below is a table of comparisons using a "hello world" application.

NameTimeMemorySuperSlim6.71 ms168 kBSlim 3.111.8 ms292 kBSymfony 4.214.7 ms567 kBZend Expressive 3.216.1 ms404 kBLaravel 5.785.3 ms2160 kBLooking only at "hello world" is not a good measurement for performance of a framework. You have to consider how well a large application is performing, specifically **your**large application. You do also have to consider how quick you can develop in a framework.

The table above is interesting if you are planning to build a small microservice that are similar to "hello world".

The architecture
----------------

[](#the-architecture)

The framework is quite simple, it consists of less than 5 classes. It follows the Middleware pattern and supports Symfony's HTTP Foundation.

### index.php

[](#indexphp)

Frontend controller, its job is to create a Request and give it to the `Kernel`.

### Kernel

[](#kernel)

It creates a container from cache or from config then starts the `Runner`.

### Runner

[](#runner)

Runs the chain of middleware one by one in the order they are defined in the service declaration of `App\Runner` in `services.yaml`. The last middleware should be the router that calls one of your controller. The router will return a Response.

When the router middleware has returned a response the middleware will run again but backwards.

### Router

[](#router)

The framework ships with two routers: `App\Middleware\Router` and `App\Middleware\RouterForComplexRoutes`. The former is using just simple if-statements to match the route with a controller. This is by far the quickest way if you only got a few routes. If you have more complex `preg_match` routing or a great number of them, you might be better of with `RouterForComplexRoutes`. It uses the [Symfony 4 router](https://symfony.com/doc/current/components/routing.html)which is the fastest generic router written in PHP.

Make sure you profile your application to see which router fits you better.

### Controller

[](#controller)

Here are your normal PHP classes and normal code. Your controllers should always return a Response.

### Services

[](#services)

You are free to create how many services, value objects, database entities as you want. You can use `config/services.yaml` to register your services. By default they are autowired with the [Symfony Dependency Injection](https://symfony.com/doc/current/components/dependency_injection.html)container.

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

[](#configuration)

It is simple to configure the application. You can use environment variables or the `.env` files for host specific configuration. If you want to register services or modify behavior then check the `config/` folder.

If you know your way around Symfony configuration then you wont have any problem configuring SuperSlim.

### Database

[](#database)

Your application may want to use a database. Just pick your favorite way to connect to your database and register it as a service. Here is an example using [Doctrine](https://www.doctrine-project.org).

```
composer require doctrine/orm
```

```
# config/packages/doctrine.yaml

services:
  doctrine.config:
    class: Doctrine\ORM\Configuration
    factory: Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration
    arguments:
      - ['%kernel.project_dir%/src']
      - 'kernel.debug'
      - null
      - null
      - false

  Doctrine\ORM\EntityManagerInterface:
    factory: Doctrine\ORM\EntityManager::create
    arguments:
      - { driver: pdo_mysql, url: '%env(resolve:DATABASE_URL)%' }
      - '@doctrine.config'

  doctrine.console_helper:
    class: Symfony\Component\Console\Helper\HelperSet
    public: true
    factory: Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet
    arguments: ['@Doctrine\ORM\EntityManagerInterface']
```

```
# .env.local

DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name

```

```
namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 * @ORM\Table(name="products")
 */
class Product
{
    /**
     * @ORM\Id()
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue()
     */
    protected $id;

    /**
     * @ORM\Column(type="string")
     */
    protected $name;

    public function getId()
    {
        return $this->id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }
}
```

If you want to enable CLI support:

```
// cli-config.php

use App\Kernel;

require __DIR__.'/config/bootstrap.php';

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();

return $kernel->getContainer()->get('doctrine.console_helper');
```

```
vendor/bin/doctrine orm:schema-tool:update --force --dump-sql
```

### Templating

[](#templating)

Returning `new Response('Hello world');` is not very fun. You probably want to use some templating. Pick you favorite tool and just register it as a service. Here is an example using [Twig](https://twig.symfony.com/).

```
composer require twig/twig
```

```
# config/packages/twig.yaml

services:
  Twig\Loader\FilesystemLoader:
    arguments: ['%kernel.project_dir%/templates']

  Twig\Environment:
    arguments:
      - '@Twig\Loader\FilesystemLoader'
      - { cache: '%kernel.cache_dir%/templates' }
```

```
namespace App\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;

class MyTwigController
{
    private $twig;

    public function __construct(Environment $twig)
    {
        $this->twig = $twig;
    }

    public function index()
    {
        return new Response($this->twig->render('index.html.twig', ['name' => 'Foobar']));
    }
}
```

```
{# templates/index.html.twig #}

Hello {{ name }}!
```

### Cache

[](#cache)

Since you are building a small and super fast app, then caching is probably very important to you. Pick your favorite cache library and just register it as a service. Here is an example using [Symfony Cache](https://symfony.com/doc/current/components/cache.html).

```
composer require symfony/cache
```

```
# config/packages/symfony_cache.yaml

services:
  symfony.cache.memcached:
    class: Symfony\Component\Cache\Adapter\MemcachedAdapter
    arguments: ['@native.memcached']

  native.memcached:
    class: Memcached
    factory: Symfony\Component\Cache\Adapter\MemcachedAdapter::createConnection
    arguments:
        - '%env(resolve:CACHE_URL)%'
        - { 'persistent_id': 'super_slim' }
```

Configure an alias for `CacheInterface` to use Memcached in production.

```
# config/services.yaml

services:
    Symfony\Contracts\Cache\CacheInterface: '@symfony.cache.memcached'
```

In development we want to use the `Void` cache.

```
# config/services_dev.yaml

services:
  Symfony\Contracts\Cache\CacheInterface: '@App\Service\VoidCache'
```

```
# .env.local

CACHE_URL=memcached://localhost

```

Then use the built in `App\Middleware\Cache` to cache each URL. Feel free to improve the creation of the cache key and other logic in this class.

```
namespace App\Middleware;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;

class Cache implements MiddlewareInterface
{
    private $cache;

    public function __construct(CacheInterface $cache)
    {
        $this->cache = $cache;
    }

    public function __invoke(Request $request, RequestHandlerInterface $handler): Response
    {
        $cacheKey = sha1($request->getUri());

        return $this->cache->get($cacheKey, function (ItemInterface $item) use ($handler, $request) {
            $item->expiresAfter(3600);

            return $handler->handle($request);
        });
    }
}
```

The future of this framework
----------------------------

[](#the-future-of-this-framework)

This small project is obviously not a competitor to any of the large frameworks and it should never be treated like that. It is just an exercise to show how easy it is to build small application based on Symfony components. And if one is using an architecture similar to SuperSlim there will not be any issues upgrading to a full Symfony framework when needed in the future.

I will treat this as a hobby project. If you like it, give it a star and fork it to turn it into something you like.

Or, you could read these great articles and [build your own framework](https://symfony.com/doc/current/create_framework/index.html).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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

2633d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/401ccc5eea13c60cf807ae982af00e368e2166e2f26d8eb541dcd881a57385bc?d=identicon)[Nyholm](/maintainers/Nyholm)

---

Top Contributors

[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (22 commits)")[![hermann8u](https://avatars.githubusercontent.com/u/25859984?v=4)](https://github.com/hermann8u "hermann8u (1 commits)")[![nstapelbroek](https://avatars.githubusercontent.com/u/3368018?v=4)](https://github.com/nstapelbroek "nstapelbroek (1 commits)")

### Embed Badge

![Health badge](/badges/nyholm-super-slim/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

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

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

1.3k1.3M152](/packages/sulu-sulu)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

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