Need help with mini2?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

416 Stars 103 Forks MIT License 81 Commits 1 Opened issues


Just an extremely simple naked PHP application, useful for small projects and quick prototypes.

Services available


Need anything else?

Contributors list

# 12,752
62 commits
# 222,845
4 commits
# 12,257
1 commit

MINI2 - A naked barebone PHP application


What is MINI 2 ?

An extremely simple PHP barebone / skeleton application built on top of the wonderful Slim router / micro framework [1] [2] [docs].

MINI is by intention as simple as possible, while still being able to create powerful applications. I've built MINI in my free-time, unpaid, voluntarily, just for my personal commercial and private use and uploaded it on GitHub as it might be useful for others too. Nothing more. Don't hate, don't complain, don't vandalize, don't bash (this needs to be said these days as people treat tiny free open-source private scripts like they paid masses of money for them). If you don't like it, don't use it. If you see issues, please create a ticket. In case you want to contribute, please create a feature-branch, never commit into master. Thanks :)

Mini currently uses Slim 2.6.0.

There's also MINI 1, an earlier version of MINI2, but with totally different code! Since August 2016 there's also MINI 3, an improved version of MINI 1. While MINI2 uses Slim under the hood, MINI 1 and 3 are 100% native PHP.


  • built on Slim
  • RESTful routes
  • extremely simple: the entire application is just 2 .php files (plus external dependencies plus view templates)
  • uses Twig as template engine, others are possible (via Slim packages)
  • uses pure PDO instead of ORM (it's easier to handle)
  • basic CRUD functions: create, read, update/edit and delete content
  • basic search
  • basic AJAX demo
  • (optional) shows emulated PDO SQL statement for easy debugging
  • (optional) compiles SCSS to CSS on the fly
  • (optional) minifies CSS on the fly
  • (optional) minifies JS on the fly
  • (optional) dev/test/production switch

By default MINI allows user access to /public folder. The rest of the application (including .git files, swap files, etc) is not accessible.


  • PHP 5.3+
  • MySQL
  • mod_rewrite activated, document root routed to /public (tutorial below)

Maybe useful: Simple tutorials on setting up a LAMP stack on Ubuntu 14.04 LTS and 12.04 LTS.


MIT, so feel free to use the project for everything you like.


MINI2 - A naked PHP skeleton application on top of Slim

Support the project

Support the project Support banner tracking pixel

Installation (in Vagrant, 100% automatic)

If you are using Vagrant for your development, then you can install MINI with one click (or one command on the command line). MINI comes with a demo Vagrant-file (defines your Vagrant box) and a demo which automatically installs Apache, PHP, MySQL, PHPMyAdmin, git and Composer, sets a chosen password in MySQL and PHPMyadmin and even inside the application code, downloads the Composer-dependencies, activates mod_rewrite and edits the Apache settings, downloads the code from GitHub and runs the demo SQL statements (for demo data). This is 100% automatic, you'll end up after +/- 5 minutes with a fully running installation of MINI2 inside an Ubuntu 14.04 LTS Vagrant box.

To do so, put

inside a folder (and nothing else). Do
vagrant box add ubuntu/trusty64
to add Ubuntu 14.04 LTS ("Trusty Thar") 64bit to Vagrant (unless you already have it), then do
vagrant up
to run the box. When installation is finished you can directly use the fully installed demo app on
. As this just a quick demo environment the MySQL root password and the PHPMyAdmin root password are set to
, the project is installed in

Auto-Installation on Ubuntu 14.04 LTS (in 10 seconds)

You can install MINI2 including Apache, MySQL, PHP and PHPMyAdmin, mod_rewrite, Composer, all necessary settings and even the passwords inside the configs file by simply downloading one file and executing it, the entire installation will run 100% automatically. See the file for more infos (and the default passwords). Keep in mind that this is quick dev setup, not a perfect choice for production for sure. This should work perfectly in every naked Ubuntu 14.04 LTS.

Download the installer script


Make it executable [is this necessary ?]

chmod +x

Run it! Boooooom. Give it some minutes to perform all the tasks. And yes, you can thank me later :)

sudo ./

Installation (manual)

1. Activate mod_rewrite and ...

Tutorials for Ubuntu 14.04 LTS and Ubuntu 12.04 LTS.

2. ... route all requests to /public folder of the script

Change the VirtualHost file from

DocumentRoot /var/www/html
DocumentRoot /var/www/html/public
and from
. Don't forget to restart. By the way this is also 
mentioned in the official Slim documentation, but 
hidden quite much.

3. Edit the development database configs


edit the database credentials and fill in your values.
4. Execute the SQL statements


folder (for example with PHPMyAdmin) to create the demo database.
5. Get dependencies via Composer

Do a

composer install
in the project's root folder to fetch the dependencies (and to create the autoloader).

Basic usage

See index.php in /public. The code below will basically show /view/subpage.twig when user moves to !

$app->get('/subpage', function () use ($app) {

Same like above here, but this time the $model is passed to the route (

use ($app, $model)
), so it's possible to perform model actions (database requests, data manipulation, etc). Action getAllSongs() is called, the result $songs (obviously an array of songs) passed to the view (view/songs.twig) via
'songs' => $songs
$app->get('/songs', function () use ($app, $model) {

$songs = $model->getAllSongs();

$app->render('songs.twig', array(
    'songs' => $songs


Inside the view the data is easily rendered like this (the template engine Twig is used here). Twig makes the view extremely simple and secure. Instead of doing this

id, ENT_QUOTES, 'UTF-8'); ?>
inside your HTML-Twig-template you can simply do
{{ }}
which automatically escapes and echos
etc. Fantastic! See the full Twig documentation here.
{% for song in songs %}

    {{ }}
    {{ song.artist }}

{% endfor %}         

The content of the model (currently in

) is extremely simple, it's just some methods getting data. When the model is initialized the database connection is created automatically (just one time for sure). A typical model method:
public function getAllSongs()
    $sql = "SELECT id, artist, track, link FROM song";
    $query = $this->db->prepare($sql);

return $query->fetchAll();



Index.php holds the configs for a development environment. Self-explaining.

$app->configureMode('development', function () use ($app) {
        'debug' => true,
        'database' => array(
            'db_host' => 'localhost',
            'db_port' => '',
            'db_name' => 'mini',
            'db_user' => 'root',
            'db_pass' => '12345678'

Environment switch (development / test / production)

To implement a production config simply copy the whole config block above and replace development with production. Add an environment variable to your Apache config. More here and here.

Before/after hooks

Slim can perform things at certain points in the lifetime of an application instance, for example before everything is started. MINI uses this to perform SASS-to-CSS compiling and CSS / JS minification via external tools (loaded via Composer btw). This is inside the above development environment configuration to make sure these actions are not made in production for sure.

$app->hook('slim.before', function () use ($app) {

// SASS-to-CSS compiler @see
SassCompiler::run("scss/", "css/");

// CSS minifier @see
$minifier = new MatthiasMullie\Minify\CSS('css/style.css');

// JS minifier @see
$minifier = new MatthiasMullie\Minify\JS('js/application.js');


Why $_POST['x'] instead of Slim's post/get handler ?

Because it's simpler and more native. Feel free to use the Slim handlers if this fits more your workflow.

Why is the deletion of a song not made with a DELETE request ?

Because (against popular opinion) HTML4/5 does not support other HTTP methods than GET/POST (but the browsers themselves do). The most easy workaround is doing this with GET/POST. Please write a ticket if I'm totally wrong here.


  1. /songs/
    is not the same as
  2. Writing the initialization in the short syntax like
    $app = new \Slim\Slim(array('view' => ...));
    has some issues and might eventually break your application. Using the syntax like in index.php works fine. @see

Useful: Organize view templates in sub-folders

It's possible to organize the view templates for sure, simply do


Useful: Multiple router files

When all the routes in index.php are too much for you: Create a folder

, put your route(r)s into files like
and load them like this:
$routers = glob('../routers/*.router.php');
foreach ($routers as $router) {
    require $router;

Useful: get URL inside view (1)

Twig can get the URL, use this in the app

$twig->parserExtensions = array(
    new \Slim\Views\TwigExtension(),

and then use

{{ baseUrl() }}
in the view template.

Useful: get URL inside view (2)

Or manually add the

$app->hook('slim.before', function () use ($app) {
    $app->view()->appendData(array('baseUrl' => '/base/url/here'));

and use it in the view template via

{{ baseUrl }}
. More here.

Scripts used

SASS Compiler

CSS / JS Minifier


Injecting stuff into $app:

Slim apps

Route URL Rewriting / Installation

Change log

  • [panique] upgrade from Slim 2.5 to 2.6
  • [panique] upgrade from Slim 2.4.3 to 2.5.0
  • [sim2github] renamed model path to uppercase to fit PSR-4

Support the project

Support the project

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.