Installing Bolt with Composer

Bolt is a great little CMS, but I am not fond of the recommended installation methods because they don’t make it easy to version control your site without having to include the whole Bolt repository. Better, then, to install it as a Composer library. These instructions are based on these ones, modified to work with the latest version of Bolt.

Create your project directory with the following structure:

/project
  /config
  /theme
  /web
    /bolt-public
    /files

At the root of your project create a composer.json file that looks like this:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/bolt/krumo"
        }
    ],
    "require": {
        "bolt/bolt": "dev-master"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-install-cmd": [
            "Bolt\\Composer\\ScriptHandler::installAssets"
        ],
        "post-update-cmd": [
            "Bolt\\Composer\\ScriptHandler::installAssets"
        ]
    }
}

Note that Bolt requires the bolt/krumo respository which is not published on Packagist, so you have to specify it as a GitHub repo.

Now install the dependencies with composer install.

Put your bolt configuration files in the config directory. You can start with the templates in vendor/bolt/bolt/app/config. Add a configuration entry to tell Bolt where your theme files are (you should put your template files directly inside this directory):

theme_path: /theme/

Copy the default Bolt .htaccess file (if you’re using Apache — otherwise create the equivalent configuration file for your server) from vendor/bolt/bolt/.htaccess to your project’s web, and set this directory as the root of your site in your server configuration. You will need to modify the paths referenced in the file to match the directory structure created above (the classes are placed in /web/bolt-public/classes/.

Create an index.php file in the web directory that bootstraps Bolt:

<?php
require_once '../vendor/bolt/bolt/app/bootstrap.php';

/* If you want to modify the Silex application before running it, you can do that here, e.g., */
$app->before(function (Request $request) {
    // ...
});

$app->run();

Now you should be able to browse to the root of your site and let Bolt handle the rest!