Slim- A PHP micro framework


We all love MVC frameworks but let’s face it, sometimes we just want a simple eloquent app that doesn’t really need all the libraries shipped with MVC frameworks. Most developers usually build their own app frameworks that are lightweight. It’s a good way of solving the problem but there is a better one. The main drawback of creating your own lightweight framework is that you waste valuable time developing the framework that if spent on the app would conjure up awe in your app users.

In Detail

Let’s explain this with an example and why using an MVC framework would be overkill in my humble opinion. Suppose you want to create a simple RESTful API, the API will be expected to:

  • Connect to a database
  • Return output in json, xml etc
  • Set response codes
  • Handle errors
  • Logging
  • URL routing

Adopting an MVC framework approach to the above app would introduce things like views which we do not need, we do need the model but it will probably come with an ORM framework which will have quite a handful of supporting libraries.


Furthermore, it’s used by many PHP developers to develop RESTful APIs and web services. It’s packed with rich features like URL routing, client-side HTTP caching, session and cookie encryption, etc.

So here is how middleware works: Slim adds middleware as layers around the core application. After that, the structure expands, adding new middleware layers. The last middleware layer added is the first to be executed.


  • Routing
  • Simple yet powerful routing that supports HTTP verbs like GET, POST, DELETE, and UPDATE. This allows you to design SEO friendly URLs.

  • Template rendering
  • Built in template rendering with custom view. You can also use other templating systems such as twig.

  • HTTP Caching
  • Let’s explain this with an example, every time a user access a resource on a web server, bandwidth is consumed depending on resources. Things like the favicon, css files don’t change frequently. HTTP caching allows you to tell the browser to keep the assets for some time and only request for resources that change. This improves the website’s performance and uses less bandwidth.

  • Flash messages
  • Things like validation failure, record added/updated messages need to be displayed once only then flashed. You get this out of the box with slim.

  • Secure cookies
  • Slim uses AES-256 to encrypt cookies. This sinfully improves the security of your application and makes it harder for hackers to forge your cookies.

  • Logging
  • This comes in handy when you want to record errors, warnings or info.

  • Error handling and debugging
  • Lets you define a custom error handler that is involved when things go wrong. The debug option lets your app decide whether to display the exception/error info or invoke a custom error handler when things go wrong.

Are you ready to realise your next big project idea with us?

Contact us today to discuss the idea you have and let's work together to bring it to life.

Our Clients

Some of our prestigious clients we worked with over the years.