• Bedrock

Laravel Valet and Bedrock Multisite

Valet is a great tool for local development environments on macOS. We’ve previously written about setting up Valet and Bedrock. Here are some steps for setting up Valet with a Bedrock multisite WordPress installation:

Subdomain installs

  • wp valet new bedrock-multisite --project=bedrock
  • Add to config/application.php in Bedrock:
    define('WP_ALLOW_MULTISITE', true);
    
  • Visit https://bedrock-multisite.test/wp/wp-admin/network.php to install network, select subdomain install
  • Add to .env: DOMAIN_CURRENT_SITE=bedrock-multisite.test
  • Update config/application.php again with full multisite constants:
    /**
     * Multisite
     */
    define('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE'));
    define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/');
    define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1);
    define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1);
    
  • Add the Bedrock multisite URL fixer plugin: composer require roots/multisite-url-fixer
  • Link any subdomains to current site with Valet:
    valet link test.bedrock-multisite
    valet link site2.bedrock-multisite
    

Subfolder / subdirectory installs

  • Copy the Bedrock multisite subdirectory driver into ~/.valet/Drivers/
  • wp valet new bedrock-multisite --project=bedrock
  • Add to config/application.php in Bedrock:
    define('WP_ALLOW_MULTISITE', true);
    
  • Visit https://bedrock-multisite.test/wp/wp-admin/network.php to install network, select subfolder install
  • Add to .env: DOMAIN_CURRENT_SITE=bedrock-multisite.test
  • Update config/application.php again with full multisite constants:
    /**
     * Multisite
     */
    define('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE'));
    define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/');
    define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1);
    define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1);
    
  • Add the Bedrock multisite URL fixer plugin: composer require roots/multisite-url-fixer

Thanks to Craig for the multisite subdirectory driver!

Start the discussion on Roots Discourse

Join over 5,500 subscribers on our newsletter to get the latest Roots updates, along with occasional tips on building better WordPress sites.

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?

“Easily the best WordPress email I get.” Colin OBrien

Ready to checkout?