A custom, multi-environment setup and example templates for Craft CMS
Craft Master is a starter project for Craft CMS.
To create a new project:
composer create-project barrelstrength/craft-master
Follow the Craft CMS docs Installation Instructions as appropriate.
To get setup with a Craft CMS project using Craft Master:
.envand add your
ENVIRONMENTand database connection info
config/local/general.phpand update as desired
Craft provides a framework for configuring a project across multiple environments using environment variables (at the infrastructure level) and multi-environment configs (within the application). Craft Master is designed to work out of the box with the recommended Craft configuration and add flexibility to support a broader range of application configurations.
Craft Master updates the default Craft starter project in the following ways:
localas the default
.multienv.phpand dynamically set the
config/db.phpto use multi-environment config and fallback to default settings if being used with application level configuration
defaultSearchTermOptionsto allow fuzzy searches
securityKeyto support both
.envor fallback to a value defined in
rememberUsernameDurationto one month
config/general.phpto support a local override file
config/local/general.phpthat can be excluded from the repo
config/local/general.phpwith extended login times and several development considerations
Craft Master prefers to keep all project files in the repository and includes the
vendorfolder to track and deploy changes.
Craft Master updates
config/multienv.phpwhich adds support for defining the
SITE_URLvariables as part of the web request. The
SITE_URLvariables are used in the
config/general.phpfile to help define several other settings.
The Site URL setting is used in several places and can be defined in the
.envfile on a per-environment basis.
Alternatively, Craft Master will dynamically set the
SITE_URLvariable if no Site URL is defined in the
.envfile. This is done using the
$_SERVER['HTTP_HOST']variable. If you choose this method, be sure your application is using an environment where
$_SERVER['HTTP_HOST']can be trusted. If you are unsure, play it safe and define your Site URL using
Alongside these conventions, Craft Master sets the
@webalias dynamically, to help avoid an undesired side effects (such as cache poisoning) if
@webis used with its default behavior.
config/db.phphas been updated to work in concert with
.envso it's easier to use the recommended Craft
.envalongside alternative workflows without the need to define some variables multiple times.
For local development, define your database credentials in the
.env. In other environments, you can choose to use
.envor a multi-environment application configuration.