I have been laravel user for a year and half, since Laravel 4 beta was published. I love how it handle things with simple and elegant syntax, make a lot difficult task done faster, and easier. Laravel is great when I need to build middle-to-large project. But then I feel it is too bloated when I work on simple project, so I start looking at simpler solution using micro-framework like Slim or Silex to build my simple project.

I start with Slim and start to search composer package to create simple MVC environment with Slim. Since Slim only provide dependency container, router and some basic but nice feature, including the View part, I need to find a way to build the Model, and the Controller part to work nicely with Slim.

The Model Part

Due to my familiarity with Laravel environment, I decide to use Eloquent ORM for the model part. Eloquent offer a lot of easy-to-use and powerful feature. We can easily register eloquent instance to the Slim container, so we can make them work together.

The View Part

Fortunately the creator of Slim already provide Slim-Views package, that made Slim have the View part of MVC which support Twig and Smarty natively, I prefer to use Twig for personal reasons, but you can switch to smarty or build custom Views as you wish.

The Controller Part

Recent Slim release now support routing to the controller method instead only route to closure. Here, I am using Slim-Facades, which provide simple static API to access Slim features and link the Slim router to the controller, so we can work with Slim in Laravel like environment :D. You can point route path to controller similar to Laravel route

Additional Package

As almost all of my application need an authentication system, so I decide to add Cartalyst Sentry as authentication provider. You can also add and configure more package via composer.json

The SlimStarter was built

Finally, after few hours mixing and matching the composer package, I write a glue code to make Slim and other package work together in MVC environment, you can grab it on my github repository and start writing your MVC application with Slim

https://github.com/xsanisty/SlimStarter

It still in early stage of development, and need many improvement, architectural design and unknown bug, but at least it works for now 😀

Configuration

You can configure SlimStarter by creating new configuration file or edit the existing in app/config path. All configuration file will be loaded on while SlimStarter is bootstrapped.

Routing

Route can be configured in app/routes.php, similar to Laravel routing

 Model

You can write model in anywhere as long as the directory is registered in composer json, but to be more clear, let’s put it in the app/models directory. Since Eloquent is used as the ORM, it has almost all of Eloquent feature, but please noted that some of Eloquent features are not included to keep the application size as small as possible, method like remember(), validate(), and paginate() will throw an exception when invoked.

 Views

All template and views file remain in app/views directory, and can be rendered via View::display() method

You can try the live demo on shared hosting here or pagodabox cloud hosting here.

I’d love to hear your tough, suggestion, advice, and critics.[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]