Laravel Herd
Last modified on Tue 30 Dec 2025

At Infinum we use Laravel Herd as it provides a simple way to set up a local development environment. Herd is available for macOS and Windows. Installation on a clean setup is really easy you just download the installer for MacOS or download the installer for Windows and run it. It will install all the necessary software and set up the environment for you.

For more details follow the official documentation for MacOS or official documentation for Windows

Tips and tricks

Fixes

As no project is perfect, you might encounter some issues with Laravel Herd. Here are some of the most common ones and how to fix them.

All 404 images are redirected to home page.

If you are using Laravel Herd and you are getting 404 errors for images the request will redirect to the home page. To fix this and get the correct broken image you can set this script in your laptop and include it to wp-config.php file on every project.

THIS FILE SHOULD NOT BE COMMITTED TO THE REPOSITORY!!!

File wp.php should be placed on your laptop:

<?php

/**
 * This file is used to check if static files exist and return the correct 404 header if they don't.
 * Used with Laravel Herding to ensure the correct 404 header is returned for non-existing files and prevent unnecessary 301 redirects.
 * To use, add the following code to your config.php file and change the path to the wp.php file.
 *
 * require_once '/Users/<your-username>/projects/server/wp.php';
 *
 * THIS FILE SHOULD NOT BE COMMITTED TO THE REPOSITORY!!!
 */

declare(strict_types=1);

if (!isset($_SERVER['REQUEST_URI'])) {
    return;
}

// Find the file path.
$filePath = ABSPATH . \trim(\parse_url($_SERVER['REQUEST_URI'], \PHP_URL_PATH), '/');

// Get the file extension.
$extension = \pathinfo($filePath, \PATHINFO_EXTENSION);

// Check if the file exists and it has an extension so we know it's a static file.
if ($extension && !file_exists($filePath)) {
    // Return 404 header if the file doesn't exist.
    \http_response_code(404);

    // Exit the script.
    exit;
}

Usage in wp-config.php file:

require_once '/Users/<your-username>/projects/server/wp.php';

This will ensure that if the file doesn't exist, it will return a 404 header and prevent the redirect to the home page.