WordPress Substratum
WordPress boilerplate configured and managed with Composer and PHP dotenv. Based on Roots Bedrock., (*1)
Features
- Improved directory structure
- Dependency management with Composer
- Easy WordPress configuration with environment and constants files
- Environment variables with PHP dotenv
- Enhanced security (separated web root and secure passwords with roots/wp-password-bcrypt)
Requirements
Prerequisites
Install Composer:, (*2)
$ curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
Installation
$ composer create-project handpressed/substratum {directory}
$ cd {directory}
Replace {directory}
with the name of your new WordPress project, e.g. its domain name., (*3)
Configuration
Open the .env
file and add your new project's home URL (WP_HOME
) and database credentials (DB_NAME
, DB_USER
, DB_PASSWORD
). You can also define the database $table_prefix
(default is wp_
) if required., (*4)
Set your project's vhost document root to /path/to/{directory}/web
., (*5)
Themes
Add themes in web/app/themes
as you would for a normal WordPress install., (*6)
Plugins
WordPress Packagist is already registered in the composer.json
file so any plugins from the WordPress Plugin Directory can easily be required., (*7)
To require a plugin, add it under the require
directive in composer.json
or use composer require <namespace>/<packagename>
from the command-line. If it's from WordPress Packagist then the namespace is always wpackagist-plugin
, e.g.:, (*8)
$ composer require wpackagist-plugin/wp-optimize
Whenever you add a new plugin or update WordPress core, run composer update
to install your new packages., (*9)
The plugins
and mu-plugins
directories are .gitignore
d by default since Composer manages them. If you want to add plugins to those directories that aren't managed by Composer, you need to update .gitignore
to whitelist them:, (*10)
!web/app/plugins/plugin-name
, (*11)
Note: Some plugins may create files or directories outside of their given scope, or even make modifications to wp-config.php
and other files in the app
directory. These files should be added to your .gitignore
file as they are managed by the plugins themselves, which are managed by Composer. Any modifications to wp-config.php
that are required should be moved to conf/wp-constants.php
., (*12)
Constants
Put custom core, theme and plugin constants in conf/wp-constants.php
., (*13)
Directory Structure
โโโ composer.json โ Manage versions of WordPress, plugins and dependencies
โโโ .env โ WordPress environment variables (WP_HOME, DB_NAME, DB_USER, DB_PASSWORD required)
โโโ conf โ WordPress configuration files
โ โโโ wp-constants.php โ Custom core, theme and plugin constants
โ โโโ wp-env-config.php โ Primary WordPress config file (wp-config.php equivalent)
โ โโโ wp-salts.php โ Authentication unique keys and salts (auto generated)
โโโ vendor โ Composer packages (never edit)
โโโ web โ Web root (vhost document root)
โโโ app โ wp-content equivalent
โ โโโ mu-plugins โ Must-use plugins
โ โโโ plugins โ Plugins
โ โโโ themes โ Themes
โ โโโ uploads โ Uploads
โโโ index.php โ Loads the WordPress environment and template (never edit)
โโโ wp-config.php โ Required by WordPress - loads conf/wp-env-config.php (never edit)
โโโ wp โ WordPress core (never edit)
See Roots Bedrock documentation for further details., (*14)
See Also
WordPress Multitenancy Boilerplate, (*15)
Credit
Inspired by roots/bedrock and wpscholar/wp-skeleton., (*16)