# Slim 4 MVC Skeleton

**URL:** <https://discourse.slimframework.com/t/slim-4-mvc-skeleton/3372>\
**Category:** Show and Tell\
**Created:** [August 21, 2019, 11:57am UTC](https://discourse.slimframework.com/t/slim-4-mvc-skeleton/3372 "2019-08-21T11:57:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![semhoun](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/semhoun/32/943_2.png) [@semhoun](https://discourse.slimframework.com/u/semhoun)\
**Post date:** [August 21, 2019, 11:57am UTC](https://discourse.slimframework.com/t/slim-4-mvc-skeleton/3372/1 "2019-08-21T11:57:43Z")

</div>

Hi,

I just want to share a skeleton I made for my company.

> **[semhoun/slim-skeleton-mvc](https://github.com/semhoun/slim-skeleton-mvc)**
>
> Slim 4 MVC Skeleton. Contribute to semhoun/slim-skeleton-mvc development by creating an account on GitHub.

The skeleton use:

- PHP-DI
- Slim-Psr7
- Doctrine
- Twig
- Flash messages
- Monolog
- Synfony console.

I want your feedback (especially to optimize the Readme).

Thanks,

---

<div class="post-metadata">

**Author:** ![l0gicgate](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@l0gicgate](https://discourse.slimframework.com/u/l0gicgate)\
**Post date:** [August 21, 2019, 4:24pm UTC](https://discourse.slimframework.com/t/slim-4-mvc-skeleton/3372/2 "2019-08-21T16:24:26Z")

</div>

This is great, I feel like we should add these on the Slim 4 readme and include them on the website to give more options to users!

---

<div class="post-metadata">

**Author:** ![Mikalay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/mikalay/32/720_2.png) [@Mikalay](https://discourse.slimframework.com/u/Mikalay)\
**Post date:** [August 21, 2019, 4:32pm UTC](https://discourse.slimframework.com/t/slim-4-mvc-skeleton/3372/3 "2019-08-21T16:32:12Z")

</div>

Thanks a lot to the author for the Slim 4 MVC Skeleton.

However, in my opinion, it turned out quite confusing, and difficult for a beginner.  
If this is presented as a starter pack - it is probably difficult.

My opinion is subjective … maybe I lack understanding due to the lack of a lot of experience …

ps this is not criticism, this is the opinion of a beginner

---

<div class="post-metadata">

**Author:** ![semhoun](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/semhoun/32/943_2.png) [@semhoun](https://discourse.slimframework.com/u/semhoun)\
**Post date:** [August 21, 2019, 7:38pm UTC](https://discourse.slimframework.com/t/slim-4-mvc-skeleton/3372/4 "2019-08-21T19:38:42Z")

</div>

I agree, my skeleton is not really for beginner.  
I tried to create a root for a project, I’ve made a more complex skeleton for Slim 3 and I used it as a start for 2 professional project.

Maybe I can’t try to make a simplier skeleton just with Twig and Monolog (like a MVC “hello world”) or maybe [https://github.com/odan/slim4-skeleton](https://github.com/odan/slim4-skeleton) is already a good one ?

---

<div class="post-metadata">

**Author:** ![ediv](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/ediv/32/996_2.png) [@ediv](https://discourse.slimframework.com/u/ediv)\
**Post date:** [December 2, 2019, 4:33pm UTC](https://discourse.slimframework.com/t/slim-4-mvc-skeleton/3372/6 "2019-12-02T16:33:57Z")

</div>

Thanks @semhoun, always super useful to see how other people are actually doing stuff.

One thing I wanted to bring up for discussion is how you’re injecting the container into your BaseController. I had avoided doing something similar to this in trying to stick with the whole ‘your app should not know about the container’ notion, but by injecting a ContainerInterface you are side stepping the major issue there (coupling your code to a specific di container implementation). In doing this, I think you end up with a cleaner way of interfacing with your controllers’ dependencies, but I’m curious how others who adhere to keeping ‘knowledge’ of the container out of the app view this approach.

Is it OK that the app knows that it relies on _a_ container, so long as the implementation is abstracted away behind an interface?

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [December 2, 2019, 5:30pm UTC](https://discourse.slimframework.com/t/slim-4-mvc-skeleton/3372/7 "2019-12-02T17:30:31Z")

</div>

Injecting the container and then fetching dependencies from it is a so called [service locator anti-pattern](https://freecontent.manning.com/the-service-locator-anti-pattern/).

A service locator hides the real dependencies and makes it harder to write tests. This pattern is only useful within a container definition closure, but should not be used in the application itself. The core application should be unaware of the container. The default approach should be to apply **Constructor Injection** (IMHO).
