PHP Slim Review 2019-10-26 on Kenneth Dodrill

A short review of the popular minimal PHP framework, Slim.



When I first started getting ideas about this blog, I decided that I wanted to make it from scratch. I could've used many services or frameworks built for blogs, but I really wanted to make a full application on my own using a myriad of modules and components. Slim PHP really stood out to me because of it's minimalist approach.

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.


Setup was fairly simple. Once I had my initial project structure set up (initializing composer and my folder skeleton) I installed it and followed the guide on Slim's website. However, during this initial setup I noticed that the setup guide was very, very simple and includes some bad practices. Separating out your application boot logic is important, but there's a lot of "dump everything here" in Slim's guide.

I have seen this before in other project documentation, and I'm sure it's just because it's a "one size fits all" type of thing. Regardless, first red flag.


At first, I was pretty impressed with Slim. I enjoyed writing with it because of its minimalist nature. For the most part, after initial set up it does not really get in the way. The Response and Request classes are very easy to use and make for simple routing.

One of my favorite things about Slim is that it allows you to switch out many of its components with whatever you want. For instance, one of the first things I did early on was switch out the DI container (Slim uses Pimple) in favor of The PHP League's Container. This container's usage just makes more sense to me than Pimple, and it includes features such as auto wiring.

Another thing I like about Slim is that its router is based on nikic's FastRoute, which is very simple (are you seeing a theme here?). Creation and grouping of routes just makes sense, like the people who made it actually use it for their enjoyment (hmm, imagine that).


Notice that the "Pros" section above starts with "At first". The reason for that is that even if I like many things about Slim, it still remains that your code is only as good as your documentation. Slim's sub-par.

At first glance, the documentation looks rather nice. There's a search bar and a sidebar containing categorized links - the structure is good. The problem lies in how the site handles different versions, which is that it doesn't. Despite having a dropdown to choose what version you want to look at documentation for, you will sometimes end up on a page for a different version. This is because the search bar will look for ANYTHING, across ALL VERSIONS. So you may end up on a v2 page because you are looking for documentation that, for some reason, does not exist in the v3 docs.

Example, go to Slim's docs and search for "Middleware". The first link will take you to the Middleware section of the v2 guide (what?). The last links will take you to the Middleware section of the v3 guide. There is no distinction in the search results. I suffered from this exact example by writing out all of my middleware the v2 way, just to have it not work, spending time to try and fix it and then realizing that I was on the wrong version of documentation. Once switching my code over to the v3 middleware, it worked flawlessly.

End thoughts

So, there you go, my little review of the Slim PHP framework. Overall, I think it's a good framework to use for writing minimal APIs or creating small static sites. But there are so many other options out there that have great tooling and much better documentation.

If you can get past the headache that is the documentation, Slim PHP is a good, minimal framework that is easy to set up and fun to write with.