Support the ongoing development of Laravel.io →
Article Hero Image

Quickest way to setup PHP Environment (Laravel Herd + MySql)

13 Dec, 2024 4 min read

Photo by Marc Serota on Unsplash

Setting up a local development environment can be a time taking hassle—whether it's using Docker or manual installations.

Laravel Herd changes that! It’s a native app for both Windows & macOS that comes with everything you need to get started: PHP, nginx, Node.js, Dnsmasq. If you upgrade to Herd Pro, you also get MySQL, PostgreSQL, Redis, and even testing and debugging tools.

In this article, we’ll explore FREE Laravel Herd and show you how to set up MySQL + phpMyAdmin manually to complement Herd’s FREE version.

image

Why Laravel Herd?

I love Herd because it’s designed to be a “plug-and-play” solution. Once installed, you can enjoy the entire development stack without the hassle of multiple installations or dealing with your system's services or configs.

It takes care of local site routing with *.test domains. For example, if you create a Laravel project named my-app, you can access it directly via http://my-app.test.

No DNS setup. No complicated configurations. Just smooth, efficient development.

What I Love the Most:

  • Two-click installation for both macOS & Windows.
  • Switch between PHP 7.4 - 8.4 in seconds, with version pinning for each site.
  • PHP and Node version update notifications.
  • Manage Node.js versions easily with built-in nvm, switching via terminal or Herd UI.
  • Share local sites on the internet instantly using Expose.
  • Start, stop, configure or install services with a simple UI.

How to Install Laravel Herd

Installing Laravel Herd is simple. If you’re running macOS 10.14+ or Windows 10+, here’s how to get it up and running:

  1. Download Herd: Head to the official Herd website and grab the installer for your OS.
  2. Run the Installer: Run the downloaded installer with administrator permissions and follow the setup steps.
  3. Verify Installation: Open Terminal (macOS) or Command Prompt (Windows) and run these commands to confirm the installation:
php --version
laravel --version
composer --version
node --version

That's it! You now have a full PHP Laravel development environment ready to go.

Note: Before installing Herd, make sure you don’t have conflicting services running in the background that use the same ports as Herd (like port 80 for web or 3306 for MySQL).

How to Set Up MySQL & phpMyAdmin

MySQL isn’t included in the free version of Herd, but you can manually set it up and integrate it easily. Here’s how:

MySQL Setup

For Windows:

  1. Download MySQL from the official MySQL website.
  2. During installation, set a root password and enable MySQL as a service.

For macOS:

  1. Install Homebrew.
  2. Run brew install mysql.
  3. Set up the root password using mysql_secure_installation.

phpMyAdmin Setup

  1. Download the latest phpMyAdmin from phpMyAdmin.net.
  2. Extract the phpMyAdmin folder.
  3. Open the folder in the terminal and link phpMyAdmin with Herd by running:
herd link
# or 
herd link custom-domain

This automatically configures hosts and nginx for you. If the folder was named phpmyadmin, you can now access phpMyAdmin via a .test domain like http://phpmyadmin.test.

To secure it with HTTPS, run:

herd secure

No further configuration is needed. Simply login with your MySQL credentials and start managing your databases.

How to Use Laravel Herd

Once Laravel Herd is installed, you can use the following commands to get started:

  • Start/Stop/Restart: herd start | stop | restart
  • Link/Unlink Projects: herd link | unlink
  • Secure/Unsecure Domain: herd secure | unsecure
  • Switch PHP/Node.js Versions: herd use [email protected] | node@14
  • Expose/Stop Expose Session: herd expose | stop expose

Supported Frameworks

Did you notice that phpMyAdmin isn't a Laravel web app but still runs perfectly with Herd? That’s because Herd isn’t limited to Laravel development. It supports a wide range of frameworks, including:

  • Laravel
  • Symfony
  • Slim
  • WordPress
  • Magento 2

If Herd doesn’t support your framework out of the box or you use a custom setup, you can create a custom driver to serve your site with Herd.

Where Can I Find php.ini?

Want to enable a specific PHP extension or adjust settings like memory limits? You can easily access the php.ini file. Just go to Herd Settings > PHP, right-click on the PHP version you’re using, and you’ll find the php.ini option in the context menu. You can also adjust things like memory_limit and max_upload_size from the same window.

Conclusion

Laravel Herd simplifies your local Laravel setup, giving you a lightweight, powerful, and easy-to-manage development environment. Whether you’re building Laravel apps, WordPress websites or Magento e-commerce—Herd has everything you need for smooth, hassle-free development.

Download Herd, set it up, and start coding with no fuss! 🚀

Last updated 2 days ago.

driesvints liked this article

1
Like this article? Let the author know and give them a clap!

Other articles you might like

Article Hero Image December 13th 2024

How to add WebAuthn Passkeys To Backpack Admin Panel

Want to make your Laravel Backpack admin panel more secure with a unique login experience for your a...

Read article
Article Hero Image December 5th 2024

How to set up Laravel Magic Link?

User authentication is crucial for making web applications secure and easy to use. Traditionally, pa...

Read article
Article Hero Image December 9th 2024

Access Route Model-Bound Models with "#[RouteParameter]"

Introduction I've recently been using the new #[RouteParameter] attribute in Laravel, and I've been...

Read article

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.