← Other topics

Migrate from Laragon to Laravel Herd

Video Notes

In this guide I’ll show the steps for migrating a Laravel application and MySQL database that was previously running via Laragon to running via Laravel Herd. These instructions should also work for a basic non-Laravel PHP application.

Summary of steps

Step 1. Export MySQL databases from Laragon

The following steps describe exporting any databases (structure and data) you currently have in Laragon’s MySQL. Later, you will then be able to import these databases into an independent MySQL service we will set up.

If your development database(s) use Laravel migrations and seeds, you could skip this step as you can just use your migrations and seeds to generate your databases and data in the new independent MySQL service.


To export our databases from Laragon’s MySQL, we’ll use HeidiSQL - the MySQL program that comes with Laragon. To open HeidiSQL click the Databases button on the Laragon interface. It will open a Session manager dialog prefilled as follows:

HeidiSQL session manager from Laragon

Click Open to initiate the connection.

Once connected, locate the database you wish to migrate from the list on the left and right click it then choose Export database as SQL.

Export a database as SQL from HeidiSQL

In the screen that appears, set these options:

  • For Databases check Create
  • For Tables check Create
  • For Data select Insert

Then next to Filename click the file icon and in the dialog that appears, specify a location and file name for your database export (mine is called mydemo.sql and I’m saving it to my Downloads folder.)

With these settings in place, click Export.

HeidiSQL export settings

You can repeat the above steps for as many databases as you wish to migrate over.

When you’re done, click Stop in Laragon so all your Laragon services, including MySQL, are stopped.

Laragon stop all services

Step 2. Set up an independent MySQL service to use with Herd

Visit https://dev.mysql.com/downloads/installer/ to download a MySQL installer. The MySQL installer will give you the options install a MySQL server as well as some MySQL-related add-ons.

Of the two installer options, choose the smaller one (~2mb) called MySQL-installer-web-community. This smaller installer will download the programs we choose as part of the install process; the larger installer includes all the programs by default and is only useful if you need to complete the install without an internet connection.

Choosing a MySQL installer for Windows

When the download is complete, run the installer. For my setup, I will choose the Server only install, but you can check out Custom if you want to install any MySQL add-ons.

You can then click Next to proceed through the several install steps, leaving everything as the defaults provided. The only step you need to provide input for is when it prompts for a MySQL Root Password. Enter a password of your choosing; in my example I use the password demo.

MySQL installer steps on Windows

When the installation is complete, the MySQL server should be installed and automatically running.

To manage the MySQL server, you can load Window’s Services app by searching for Services from the start bar.

Of the services listed, you should see MySQL and once selected you can choose to Stop, Pause, or Restart the service.

Managing MySQL via Window’s Services app

Step 3. Import databases into new MySQL service

Next, we need to import the database(s) we exported earlier into our new MySQL service. If you plan to build your database and tables via Laravel migrations and seeds you can skip this step.


Returning to HeidiSQL, connect to your new MySQL service using the following settings:

Connect to MySQL service from HeidiSQL

Once connected, from the File menu choose Run SQL File.

In the dialog that appears, locate the MySQL backup file you made in Step 1 (in my case that was the file at ~/Downloads/mydemo.sql).

When you see the message asking "Really auto-detect file encoding?" click Yes.

Run SQL file from HeidiSQL

When the import is complete, you should see your newly imported database in the list of databases on the left. If you don’t, right click and click Refresh.

Refresh to see newly added database

Repeat the above steps for any other databases you wish to import.

Step 4. Install Herd

If you haven’t already done so, download and install Herd: https://herd.laravel.com

If you’re new to Herd, check out my overview video: Laravel Herd released for Windows - Easy PHP local development.

Step 5. Move site contents

To move our site contents from Laragon to Herd, we’ll simply move the site directories.

  • From: C:/laragon/www/
  • To: ~/Herd (Where ~/ is a shortcut for your Home directory).

You can do this move via the File Explorer or a command line program, e.g.:

> mv c:/laragon/www/mydemo ~/Herd

Be sure to replace mydemo with the name of your site folder.

Alternatively, if you don’t want to move your files, you could set C:\laragon\www\ to be one of the directories Herd watches for new sites. Find this option in Herd under General > Herd paths

Once your site directory is moved, Herd should autodetect it and generate a new test URL:

Herd detects new site moved from Laragon

Step 6. Update site database configs

Next we need to update our site’s .env file so the database related configs can connect to our database in our new MySQL service. All of the settings should be the same from what they were with Laragaon’s MySQL with the exception of needing to add a value for DB_PASSWORD. Example:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydemo
DB_USERNAME=root
DB_PASSWORD=demo

Step 7. Test it

If all went well, you should be able to load your application and confirm the database connection is working: Testing application running in Herd

Step 8. Composer and PHP from command line

When working on Laravel applications, we often need access to Composer and PHP from command line.

For example, we run commands like composer update to get our latest Composer dependencies. Or we run php artisan to invoke Laravel’s built in command line utility.

Herd comes with Composer and PHP built-in (you’ll find them in ~/.config/herd/bin) and they can be readily invoked via PowerShell. Example:

C:\Users\Susan> php --version
PHP 8.3.6 (cli) (built: Apr 10 2024 14:53:44) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies

C:\Users\Susan> composer --version
Composer version 2.7.2 2024-03-11 17:12:18
PHP version 8.3.6 (C:\Users\Susan\.config\herd\bin\php83\php.exe)
Run the "diagnose" command to get more detailed diagnostics output.

If you use Git Bash or Cmder instead of PowerShell, check out my follow-up video: PHP/Composer via Herd from Git Bash or Cmder (coming soon).

Step 9. Running Composer update

The first time you run composer update in your newly migrated site, you may receive a warning about ambiguous class resolutions.

To resolve this warning, delete your application’s /vendor directory and rebuild it by running composer update again.

I believe this issue occurs because the /vendor directory contains Composer classmap configuration files that may be referencing paths relative to the directory your application used to live in. By removing and rebuilding the /vendor directory, it ensures all paths are relative to your application’s new location.

If this info helped you out, you can send a tip via PayPal. Thanks for your support!
← Other topics