Bedrock

Table of Contents

Create a Bedrock WordPress installation

For these examples, the project name is “theproject”.

composer create-project roots/bedrock [theproject]
cd [theproject]
composer update

Then edit .env:

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.

Remove default themes

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.