laravellaravel-valetdynamic-urlvalet

How can I link several domains to one Laravel project?


I have this one project, that has 3 databases and 1 dynamic page, which takes content from those databases. I need 3 different URLs (url1.test, url2.test, url3.test), each should contain one page, filled with data from assigned database. How can I do that? I tried valet, but can "park" only the whole project.

Here is the code of my controller function.

    public function instance ($dbname) {
        $json = DB::connection($dbname)->select('select json from config')[0]->json;
        $config = json_decode($json, true);
        if ($config['status'] == 'enabled')
            return view('instance', ['config'=>$config]);
        else
            return view('blocked');
    }```

Solution

  • The park command is used to tell Valet where to look at to find projects. In your case, you want to link a different domain to your project.

    What you need to do is go inside your project folder and run valet link url2. This way, url2.test will be linked to your app.

    More info: https://laravel.com/docs/8.x/valet#the-link-command