Project setup & structure


This guide assumes you have already configured your local development environment with composer installed. If you need guidance on this, please follow the SilverStripe CMS open source documentation on Getting Started.

It also assumes you have access to your stack’s Gitlab repository which is provided to you by SilverStripe.

Getting started

If your SilverStripe Platform stack has already been built you can simply clone your repository to your local environment and run composer install.

Note:This documentation assumes that that public root of your website is /var/www/mysite/www.

git clone [Gitlab Repo URL] /var/www/mysite/www
cd /var/www/mysite/www
composer install

If your stack has not been built you can use the Platform’s base project to get started:

composer create-project silverstripe/platform-project /var/www/mysite/www

Note: silverstripe/platform-project differs from the commonly used silverstripe/installer for installing SilverStripe CMS via Composer. It includes the required module dependencies and platform configuration file

At this point you will still need to configure the database and usually default admin for your environment.

This must be done using SilverStripe CMS’s Environment Management (a _ss_environment.php file). This file should not be committed to the git repo as you may expose sensitive credentials.

An example _ss_environment.php file is show below and should reside on your local development environment’s webroot (/var/www/mysite/www) or a directory higher ( /var/www/mysite):

<?php // _ss_environment.php

ini_set('date.timezone', 'Pacific/Auckland');

// Which kind of environment: dev, test, live
define('SS_ENVIRONMENT_TYPE', 'dev');
if(SS_ENVIRONMENT_TYPE == 'dev') {
	ini_set('display_errors', 1);
	ini_set('display_startup_errors', 1);

// This defines a default database user
define('SS_DATABASE_SERVER', 'localhost');
define('SS_DATABASE_NAME', 'SS_mysite');
define('SS_DATABASE_USERNAME', 'root');
define('SS_DATABASE_PASSWORD', 'rootpass');

// This defines a default cms user
define('SS_DEFAULT_ADMIN_USERNAME', 'admin');
define('SS_DEFAULT_ADMIN_PASSWORD', 'password');

$baseDir = realpath(dirname(getcwd()));
$_FILE_TO_URL_MAPPING[$baseDir] = 'http://localhost/';

Navigate to http://localhost/ in your browser where ‘localhost’ is your website host name. You should see your database schema being built and then you will be redirected to the home page of the site.

Import an existing project

If you have an existing git repo you can add the new SilverStripe Platform repo as a remote and push to Gitlab.

cd /var/www/mysite/www
git remote add ssplatform [Gitlab URL]
git push -u ssplatform master

There are a few project requirements below which you should ensure your project adheres to.

Project requirements

  • Modules should be installed using composer
  • You will need to include some modules in your project, see the SilverStripe Modules section.
  • You should follow the project structure as shown below
  • You should include the .platform.yml in the root of your project

The default SilverStripe Platform installer will include all required modules and a default .platform.yml file.

Project structure

After creating your project your should have a structure similar to below:


Database Credentials

Database parameters are configured outside of your project in the _ss_environment.php file, which is managed by SilverStripe Platform. To ensure a successful deployment your mysite/_config.php file should look similar to the following:

global $project;
$project = 'mysite';

global $database;
$database = ''; // This must be left blank

// This includes _ss_environment.php and configures your application

Deploying your project

To deploy your project, please see the deployments documentation.

Importing database & assets

For information on how to import your database and assets please refer to the snapshots documentation.