Risan Bagja

Windows, PHP 8, Laravel Subdomain Routing

Install PHP 8 on Windows

Today I managed to install the latest PHP version 8 on my Windows machine. It’s a pretty straightforward process:

Host File Location on Windows

On Windows 10, the host file is located at:


The format is the same as the one found on Linux or macOS. So unfortunately you cannot set a wildcard subdomain entry too.   foo.example.com      # Some comment      project.test      secret.project.test

Laravel Subdomain Routing

I know that Laravel has support for subdomain routing for a long time. It goes as early as version 4 in 2013—the first version of Laravel that I used. But I never really tried that feature, until today. It just works out-of-the-box. Of course, you still need to properly configure your webserver to point those subdomains to your Laravel’s public directory. But it still blew my mind.

Route::domain('{user}.example.com')->group(function () {
    Route::get('/messages/{id}', function ($user, $id) {
        // Get the {user} value through $user