Herd: Share project configuration with team members

Laravel Herd is awesome for solo developers but with the new update it’s even cooler including amazing features one of which is sharing your project configuration and services with your team members so that they are running the correct versions of services on the right port number.

Working solo on a project most of the times is awesome, you have all the services that the project needs running in your machine, you code like no is watching you and you are just on your own until a member joins which is also great, that means the project that you gave so much efforts is growing and it needs more developers to manage. That’s where you need to create a sort of templates that your team members can follow to use the same services that you are using for the project.

If you are using Herd to run your project then you might need to update Herd to the latest version (v1.11) where Herd introduced a feature to share configuration of your project and it’s services with your team. So let’s see how that works and how you can create that sort of template.

Herd Project Configuration

Herd uses a yml file that is created in your root directory of your project to help Herd understand what your project needs. And you don’t need to manually create that file but Herd helps you with it.

To start, just open a terminal and make sure you are in the root folder of your project in the terminal and then run herd init in your terminal, here’s a picture to show you:

start sharing laravel project configuration with team members

Herd will ask you for the name of your project that will be used as the test domain, in my case it’s wcr so my domain will be wcr.test. After you enter the name and click enter, Herd will ask you for any additional aliases you want to use (e.g. multiple domains), you can skip this part if you don’t use multiple domains or sub-domains, in my case, I will just leave it empty and proceed.

After name and aliases step, Herd will ask you for the version of PHP you are using (in my case 8.3):

Herd init PHP version

After the PHP version, the next step is either you want to serve your project via HTTPS locally or not. Since some of my project services requires HTTPS so I will go with Yes:

HTTPS Herd Init

Then Herd will ask you for any additional services you want to use, for example, Redis, Meilisearch, Reverb along with MySQL or PostgreSQL. You can use your arrow keys to see more options down below.

That was the last step for Herd configuration for your team. And now there should be a file in your project root directory called herd.yml that should contain the configuration you just made and also any other configuration for Forge or Laravel Cloud that you might have done through the Site Manager, here’s how it looks:

name: wcr
php: '8.3'
secured: true
aliases: {  }
services:
    mysql:
        version: 8.0.36
        port: '${DB_PORT}'
    redis:
        version: 7.0.0
        port: '${REDIS_PORT}'
integrations:
    forge: {  }

Now you can run herd init again to initialize the services for your project and apply the configurations that you just made. So let’s go ahead and run it:

herd initialization

And that’s it! Now you can commit and push your herd.yml file to your github repo and when a new team member joins then he can simple run herd init to start the services required on the ports that the project needs.

In case you ran into any problems, please leave a comment and I will try to help you if I can!

Here’s an official video from Laravel explaining what you just read but in a video:

If you liked the content and want support this site, you can do so by buying me a coffee.

Leave a Comment