• home /
  • articles /
  • craft cms multisite and -domain testing laravel valet

Test your Craft CMS multiple domain multi-site locally with Laravel Valet

Daaf Bleumink

14 May2 MINUTES

This is going to be a quick and informative article, so let’s dive straight in 🏄‍♂️

Prerequisites

The part where I tell you how it’s done

For this article I’m using a fresh Craft installation using this url: maindomain.test.

These are the steps I took for creating the bare essentials to test some multi-site, multi-domain sweetness:

  1. In Craft create a new site using these details: craft cms create new site
  2. From your terminal cd into your project folder
  3. Enter command valet link otherdomain

Now navigate to otherdomain.test in your browser and you will see the Craft welcome screen. But how do we see which site we are querying?

How to see which site we are querying

  1. In your code editor go into your index.twig
  2. Place the following code inside
<!-- Inside of the div with the class "content" -->
<ul>
    <li>Site ID: {{ currentSite.id }}</li>
    <li>Site Handle: {{ currentSite.handle }}</li>
    <li>Site Name: {{ currentSite.name }}</li>
    <li>Site Language: {{ currentSite.language }}</li>
    <li>Is Primary Site?: {{ currentSite.primary }}</li>
    <li>Base URL: {{ currentSite.baseUrl }}</li>
</ul>
  1. Refresh your browser
  2. Switch between maindomain.test and otherdomain.test
  3. You’ll see different details 🎉

Now you’re able to test your multi-site + multi-domain setup locally.

Now build something awesome! 🚀

Got any questions or suggestions for a better approach?
Let me know! @daaf730

Want regular updates?

Sign up for my newsletter.