A Slim Skeleton

tldr: Built a Slim skeleton app. Fork it on GitHub.

Thought I'd give the Slim framework a whirl for a recent app. It's heavily inspired by Sinatra, which is a good thing. Like Sinatra, it doesn't impose any kind of structure on your code. Also a good thing, though it's still good practice to establish some order early in our app's lifecycle. With that in mind, I created a somewhat opinionated Slim skeleton app. It uses my own fork of the Slim framework, Twig for templating and Sass for stylesheets.

The structure looks like this:


Key points:

  • The public folder is where all publicly accessible files live
  • Routing is handled by public/index.php just as you would expect for a Slim application
  • The bootstrap.php takes care of includes and starting the session
  • View & layout templates live under app/views

Slim & Rewrites

The fork of Slim allows you to use rewrites to route requests to a sub-folder whilst maintaining URLs that don't include the sub-folder's name. This method is supported by all of the other frameworks I've used. A little surprising then that Slim doesn't support this particular approach.

The app is set up so that we can point Apache at the root folder and with some .htaccess rewrites, all requests will be sent to the /public/ folder. I like this. It's useful when I'm deploying to an environment where the document root can't be changed or perhaps I'm looking to keep the web root as tidy as possible.


I like the Django template language and Twig is really similar. An easy choice really.


Sass is awesome. It's even better with Compass. The skeleton is ready to go with both.

Moz Morris

Moz Morris

Freelance Web Developer