For these examples, the project name is “theproject”.
composer create-project roots/bedrock [theproject]
cd [theproject]
composer update
Then edit .env:
Set database name, user and password. For local development, I usually choose “theproject”, “root” and “”, respectively.
Set the WP_HOME to the valet .test URL: 'https://theproject.test'
Set WPDEBUGLOG – the location of the debug.log file. I put my projects in ~/code, so for this example it would be: ‘/Users/myusername/code/theproject/web/app/debug.log’
Generate keys by going to https://roots.io/salts.html, copying and pasting the “Env Format” keys.
Create the database:
wp db create
Secure the test site:
valet secure
Then visit https://theproject.test/ to finish installing WordPress and creating your first admin user. (You can also do this with wp-cli if you prefer.)
Proceed with installing Sage 10 as the theme and activating it.
By default, all the standard twenty* themes are installed with the composer WordPress package. To remove all, we set the standard theme directory to web/app/themes in /config/application.php, for instance under the Custom Content Directory heading:
/**
* Custom Content Directory
*/
Config::define('CONTENT_DIR', '/app');
Config::define('WP_CONTENT_DIR', $webroot_dir . Config::get('CONTENT_DIR'));
Config::define('WP_CONTENT_URL', Config::get('WP_HOME') . Config::get('CONTENT_DIR'));
Config::define('WP_DEFAULT_THEME', 'WP_CONTENT_DIR' . '/themes');
But every time WordPress is updated, they will be back – so we add this to composer.json’s scripts section:
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-update-cmd": [
"composer run remove-old-wp-themes"
],
"remove-old-wp-themes": [
"rm -rf web/wp/wp-content/themes/twenty*"
],
"test": [
"phpcs"
]
}
This way, all the twenty* themes will be deleted every time a composer update is done.