BoltCM

Sophisticated, Lightweight and Simple

Jump to docs navigation
Edit on GitHub

Installation » Composer » Creating a new project

If you are starting a new project from scratch then we've made this very simple, and flexible.

Bolt's Composer based installs can be performed using either composer create-project (recommended), or building your own composer.json and path configuration file for more advanced control.

Composer create-project installs can be run interactively (installer will prompt for configuration options), or automatically (installer will use default configuration options, or alternatively options taken from environment variables).

An example of the process is shown here:

Create Project

Interactive Install

To start an interactive install, navigate to the parent directory of your desired project (site), and run the following from a command line:

composer create-project bolt/composer-install:^3.1 <MYPROJECT> --prefer-dist

NOTE: Change <MYPROJECT> to the name of your project before running the installer.

The install process will ask you some questions about your required install strategy, you can install Bolt inside a single directory, or you can install the public assets inside a public directory and keep the application code outside the web root.

Automated Install

To start an automated install, navigate to the parent directory of your desired project (site), and run either of the following commands depending on what options you desire.

Default Options

To simply use default directory locations, you just apply the --no-interaction parameter to the composer create-project command, e.g.

composer create-project bolt/composer-install:^3.1 <MYPROJECT> --prefer-dist --no-interaction

NOTE: Change <MYPROJECT> to the name of your project before running the installer.

Customised Options

If you want an automated install with customised configuration options, you can set any, or all, of the following variables and the installer will use them:

An example with all options set would look like:

env BOLT_DIR_MODE=0755 BOLT_WEB_DIR=my_public_dir BOLT_THEME_DIR=my_theme_dir \
    BOLT_FILES_DIR=my_files_dir BOLT_CONFIG_DIR=my_config_dir \
    BOLT_DATABASE_DIR=my_database_dir BOLT_CACHE_DIR=my_cache_dir \
    composer create-project bolt/composer-install:^3.0 <MYPROJECT> \
    --prefer-dist --no-interaction

NOTE: Change <MYPROJECT> to the name of your project before running the installer.

Initialise a Project

For complete flexibility over the installation of your Bolt site, you can create your own composer.json file, and path configuration file.

$ mkdir example.com
$ cd example.com

Configuration File

In order for paths to be customised and still have the standard index.php (web) and nut (CLI) work, there needs to be a standard place these are defined.

This is either bolt.yml (recommended) or bolt.php in the project root. YAML works for simple values and PHP supports any programmatic logic if required.

An example bolt.yml would look like:

paths:
    cache: app/cache
    config: app/config
    database: app/database
    web: public
    themebase: public/theme
    files: public/files
    view: public/bolt-public/view

If you are creating a bolt.php file instead, it should return the following array.

    $config = [
        'application' => null,
        'resources'   => null,
        'paths'       => [
            'cache'     => 'app/cache',
            'config'    => 'app/config',
            'database'  => 'app/database',
            'web'       => 'public',
            'themebase' => 'public/theme',
            'files'     => 'public/files',
            'view'      => 'public/bolt-public/view',
        ],
    ];

This is a very advanced option, see Bolt's bootstrap file for more details.

Composer JSON File

You will need to create a composer.json file with the following keys at a minimum:

{
    "require": {
        "bolt/bolt": "^3.1"
    },
    "minimum-stability": "beta",
    "prefer-stable": true,
    "scripts": {
        "post-install-cmd": [
            "Bolt\\Composer\\ScriptHandler::installAssets"
        ],
        "post-update-cmd": [
            "Bolt\\Composer\\ScriptHandler::installAssets"
        ],
        "post-create-project-cmd": [
            "Bolt\\Composer\\ScriptHandler::configureProject",
            "Bolt\\Composer\\ScriptHandler::installThemesAndFiles",
            "nut extensions:setup"
        ]
    }
}

Required Folders

Run the following commands to create the required folders. If you defined a different folder structure in bolt.yml or bolt.php, you have to adjust the commands to fit your own folder structure.

mkdir -p app/cache
mkdir -p app/config
mkdir -p app/database
mkdir -p public/theme
mkdir -p public/files
mkdir -p public/bolt-public/view
mkdir -p public/thumbs
mkdir -p public/extensions
mkdir -p extensions

Finally run Composer to install the required libraries and configure the installation:

composer install --no-scripts
composer run-script post-create-project-cmd
composer run-script post-install-cmd

Permissions

Generally most server should be fine with the default permissions. However, if you require guidance on setting up permissions, see our File System Permissions page.

Finishing Set-up

After you've done this, skip to the section Setting up Bolt.


Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on IRC.
Spotted a typo, or have something to add? Edit this page on GitHub.