vjaykoogu / slim-boilerplate

A simple Slim Framework based website boilerplate, pre-configured with commonly used components.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#Website Boilerplate

A website boilerplate based on the Slim Framework as well as a couple of useful Laravel Framework components, which are commonly required, when developing simple websites.


As many frameworks provide quite a lot of components and features that seem to be overhead in small projects, I came up with using the Slim Framework.

It requires PHP 5.3 to run, so it should run on quite a broad range of web application servers with PHP installed on them.

After adding the components I require most of the time, I ended up with this little boilerplate project.

##Third party software

In addition to the Slim Micro Framework, the following components are included:

Also implementing features based on:


For installation execute the following commands and replace demo by your own application name

git clone https://github.com/remluben/slim-boilerplate.git demo
cd demo
composer update



The application can be easily configured using the app/config/config.php file.

There are defined a couple of configuration values by default. They can be changed as described and new configuration values may be added as required.

The configuration object is available as as $config inside routes.php and can be injected into Controllers by using the \App\Components\Config\Config $config parameter.

####Environment based configuration

Within the application base directory exists a .env.example file, which can be used for environment based configuration.

Simply rename the file to .env and adjust the settings. Settings are read from within app/config/config.php using PHP's getenv() function.

For further information see: https://github.com/vlucas/phpdotenv

###Dependency Injection

The website boilerplate makes use of Laravel's IoC (Inversion of Control) component, which allows automatic dependency injection of Controller constructor parameters.

Let's take a look at the HomeController, that comes with the application by default:

class HomeController extends BaseController
     * @var \Slim\Slim
    private $app;

    public function __construct(\Slim\Slim $app) // automatically provided by Laravel's IoC container
        $this->app = $app;

     * Show the home page
    public function indexAction()

Note, that it is possible to automatically load any resource from the IoC container, that is registered. You can see how this works in app/bootstrap/bootstrap.php.

Further information can be found at http://laravel.com/docs/4.1/ioc


A simple router class as a wrapper for the Slim\Slim application class is available within the routes.php file as $router.

It provides a simple way to add controller based routing:

// The base namespace \App\Http\Controllers\ is set within the app/boilerplate/boilerplate.php file
// \App\Http\Controllers\HomeController
$router->get('/home', 'HomeController::index');

// A simple Slim route using the Router component
$router->get('/test/:something', function ($something) {
    echo htmlspecialchars($something);


  • Bower and Gulp integration


A simple Slim Framework based website boilerplate, pre-configured with commonly used components.

License:MIT License


Language:PHP 98.8%Language:ApacheConf 1.1%Language:CSS 0.1%