SLIM skeleton app : Why so many library pre-included in SLIM skeleton app?

Lean, bloat free and minimal micro-framework is the main characteristics of the SLIM Framework. I was going through the documentation and found first application tutorial.

When I created a new project using following command:

`    php composer.phar create-project slim/slim-skeleton [my-app-name]`

I am seeing, there are a number of library got included in vendor folder (screen shot is given below).

I know some of them are cool, but why a few of them are are there? like

  • Nikic Route : SLIM already have powerful routing system then why this one?
  • Doctrine : I m not interested in using Doctrine, I would like propel or Eloquent then why this is sitting there; may be because of monolog.
  • ContainerInterop : I am sorry, really don’t know about this.
  • Symfony/yaml : I hate everything from symfony and so yaml. Symfony exaggerate things … If I have to deal with complexity only, then why not I will choose JAVA instead of symfony or php? sorry for my rant.

However, some of them are good like Webmozart , PHPUnit. I think sample application should be lean and minimalist to match with the USP of SLIM.

Could anybody please tell me why Nikic Route in sample SLIM app? This is what infuriating me.

From the docs you’ll find about the routing:

Required packages for Slim are listed here:

1 Like

Slim’s actual dependencies are:

    "require": {
        "php": ">=5.5.0",
        "pimple/pimple": "^3.0",
        "psr/http-message": "^1.0",
        "nikic/fast-route": "^1.0",
        "container-interop/container-interop": "^1.2",
        "psr/container": "^1.0"
  • pimple/pimple is our DI container. psr/container and container-interop are interoperability interfaces to enable Slim play nice with other DI containers like PHP-DI.
  • nikic/fast-route is Slim’s router. We don’t have any other one.
  • psr/http-message is the interoperability library for PSR-7.

The skeleton has these dependencies:

    "require": {
        "php": ">=5.5.0",
        "slim/slim": "^3.1",
        "slim/php-view": "^2.0",
        "monolog/monolog": "^1.17"
  • slim/slim is obviously Slim Framework
  • slim/php-view provides a simple PHP based view renderer
  • monolog/monolog is a logging component.

The skeleton also has this development dependency:

    "require-dev": {
        "phpunit/phpunit": ">=4.8 < 6.0"

Obviously this the standard unit testing library.

Any other component you see in vendor is a dependency of PHPUnit. i.e.
the Symfony, Webmozart and Doctrine components are dependencies required by PHPUnit.


You are of course free to use any additional packages you wish, and exclude those you don’t wish to use. For any installed package, you can use composer why vendor_name/package_name to get information about which other package required it. Remember, just because the package is sitting there doesn’t mean the code is being run or that you must use it.

As for some of your specific questions, yes, Slim has a powerful routing system, which is based on nikic/fast-route. Running composer why doctrine/instantiator will tell you that there are two packages phpspec/prophecy and phpunit/phpunit-mock-objects that require it. Container-interop is required by the Slim Framework itself and is in place so that you can swap out and use whichever dependency injection container you desire, if you don’t like the default (Pimple) that ships with Slim. The symfony/yaml component is required by PHPUnit.

The takeaway here is that packages have features they desire to support, and some of those features require other packages to work. If you don’t use all of those features that is fine, your code will not run them, but Composer can’t determine what you will and won’t use for features so it installs all of the packages each package says is required.

1 Like

Thank you very much @akrabat for detailed explanation. It really helped me to understand many things. I was thinking ROUTE is internal component of SLIM and Nikic Routes is added on the top of that default router. It was my fault.

Thanks again :slight_smile:

Thanks @tflight. I got your point. I was totally wrong. Actually, long ago, I used Slim(perhaps SLIM 1) and I have some pre-conceived notion about SLIM. SLIM 3 has changed a lot. Thanks for your answer it really helped me.