All Projects → remluben → slim-boilerplate

remluben / slim-boilerplate

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

Programming Languages

PHP
23972 projects - #3 most used programming language
Twig
543 projects

Projects that are alternatives of or similar to slim-boilerplate

slim-doctrine
Slim-Doctrine managers integration
Stars: ✭ 16 (-5.88%)
Mutual labels:  slim-framework
Slim-Config
A file configuration loader that supports PHP, INI, XML, JSON, and YML files for the Slim Framework. It internally uses https://github.com/hassankhan/config.
Stars: ✭ 28 (+64.71%)
Mutual labels:  slim-framework
Slim
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
Stars: ✭ 11,171 (+65611.76%)
Mutual labels:  slim-framework
phpPgAdmin6
PHP7+ Based administration tool for PostgreSQL 9.3+
Stars: ✭ 45 (+164.71%)
Mutual labels:  slim-framework
Slim-Console
Slim Framework Console
Stars: ✭ 26 (+52.94%)
Mutual labels:  slim-framework
slim-routing
Slim framework powered-up routing
Stars: ✭ 14 (-17.65%)
Mutual labels:  slim-framework
slim-3-authentication
A Slim 3 authentication system.
Stars: ✭ 44 (+158.82%)
Mutual labels:  slim-framework
wordpress-eloquent
A library that converts converts wordpress tables into Laravel Eloquent Models.
Stars: ✭ 129 (+658.82%)
Mutual labels:  slim-framework
REST-Api-with-Slim-PHP
REST API with PHP Slim Framework 3 and MySQL
Stars: ✭ 69 (+305.88%)
Mutual labels:  slim-framework
phpindonesia.or.id-membership2
PHP Indonesia - Membership Application - Reloaded
Stars: ✭ 31 (+82.35%)
Mutual labels:  slim-framework
localization-middleware
PSR-15 middleware to assist primarily with language-based content negotiation and various other localization tasks
Stars: ✭ 24 (+41.18%)
Mutual labels:  slim-framework
slim-mobile-detect
Implements Mobile-Detect lib for Response's write on Slim Framework App
Stars: ✭ 18 (+5.88%)
Mutual labels:  slim-framework
slim-play
Slim Play app
Stars: ✭ 76 (+347.06%)
Mutual labels:  slim-framework
api rest slim framework
RESTFUL API o API REST con slim framework (PHP, MySql, PDO)
Stars: ✭ 14 (-17.65%)
Mutual labels:  slim-framework
slim3-mvc
Slim 3 PHP micro framework MVC application boilerplate
Stars: ✭ 24 (+41.18%)
Mutual labels:  slim-framework
slim-skeleton
Slim Framework skeleton application following MVC construction
Stars: ✭ 18 (+5.88%)
Mutual labels:  slim-framework
lassi
PHP boilerplate for quick start projects using Slim Framework and Eloquent.
Stars: ✭ 58 (+241.18%)
Mutual labels:  slim-framework
Slim-Restrict-Route
A Slim middleware to restrict ip addresses that will access to your routes
Stars: ✭ 21 (+23.53%)
Mutual labels:  slim-framework
sihae
A PHP 7.4+ blog engine built with Slim Framework and Doctrine ORM
Stars: ✭ 18 (+5.88%)
Mutual labels:  slim-framework
slim-skeleton
A Slim 3 skeleton project to easily bootstrap MVC applications using Slim Framework 3
Stars: ✭ 14 (-17.65%)
Mutual labels:  slim-framework

NOTE: This project is archived and not updated anymore. Please simply use any of the awesome up-to-date PHP frameworks out there, i.e. Laravel

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.

Important note

If you are looking for the slim-boilerplate for PHP 5.3, please use the v1.0.0 tag of this repository.

Why?

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 7.x to run, so it should by now 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:

Installation

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

Docs

###Configuration

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

Database

There are default MSQL database credentials provided within the app/config/config.php file as a fallback for development systems.

host: localhost
database: development
username: user
password: password

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()
    {
        $this->app->render('home.twig');
    }
}

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

Routing

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);
});

Database

The Laravel database component can be easily injected into Controllers:

class ExampleController extends BaseController
{
    /**
     * @var \Slim\Slim
     */
    private $app;

    /**
     * @var \Illuminate\Database\Capsule\Manager
     */
    private $db;

    public function __construct(
        \Slim\Slim $app,
        \Illuminate\Database\Capsule\Manager $db
    ) {
        $this->app = $app;
        $this->db = $db;
    }

    /**
     * Show the home page
     */
    public function indexAction()
    {
        $this->app->render('home.twig');
    }
}

For further information on how to use the database object see https://github.com/laravel/docs/blob/4.1/database.md

Views

The installation of the Slim Views extension allows the use of the following helper functions inside views:

  • urlFor
  • siteUrl
  • baseUrl
  • currentUrl

Roadmap

  • Additional helpful boilerplate code for various use cases
  • Bower and Gulp integration
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].