Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

filippocalabrese's avatar

How do you set up your development environment?

Hello everyone! I have been working with Laravel for several years now and have had the opportunity to try out different development environments, including MAMP, XAMP, Valet, Herd and Sail.

At the moment, I'm finding it very comfortable working with Laravel Sail, mainly for those projects I work with in teams and which therefore run the risk of carrying different issues than the platforms the individual devs use.

I would like to discuss with you what choice you have made and why. Mainly because I would like to rationalise my work more and organise myself better :)

How do you approach your development on a day-to-day basis? How do you manage the transition from different projects?

0 likes
3 replies
LaryAI's avatar
Level 58

Setting up a development environment is a crucial step for any developer, and it's great that you're looking to optimize your workflow. Since you're already comfortable with Laravel Sail, which is a Docker-based environment, it seems you appreciate the benefits of containerization. Here's a general approach to setting up and managing development environments, particularly when transitioning between different projects:

  1. Standardize the Environment: Using Docker (Laravel Sail) or another containerization tool helps ensure that all team members are working with the same configurations. This minimizes the "it works on my machine" problem.

  2. Version Control: Make sure all your projects are under version control (e.g., Git). This allows you to easily switch between different project states and collaborate with others.

  3. Automate Setup: Create scripts or use tools like Docker Compose to automate the setup of your development environment. This can include installing dependencies, setting up databases, and configuring services.

  4. Isolate Projects: Use separate Docker containers or virtual machines for different projects to avoid conflicts between project dependencies.

  5. Use Environment Variables: Store configuration in the environment. This makes it easier to change settings without altering code and helps keep sensitive information out of version control.

  6. Consistent Coding Standards: Adopt coding standards and use tools like PHP CS Fixer or ESLint to enforce them. This keeps the codebase clean and reduces friction when switching projects.

  7. Dependency Management: Use Composer for PHP dependency management and ensure that you're committing your composer.lock file to maintain consistent dependency versions across environments.

  8. Database Migrations and Seeding: Use Laravel's migration and seeding capabilities to manage your database schema and initial data. This allows any developer to set up a working database quickly.

  9. Automated Testing: Write tests and use continuous integration to automatically run them. This ensures that your application is always in a deployable state, even as you switch between projects.

  10. Documentation: Keep your project documentation up to date. This includes setup instructions, environment variables, and any special considerations for the project.

Here's an example of a docker-compose.yml file that you might use with Laravel Sail to set up a typical Laravel application:

version: '3'
services:
  laravel.test:
    build:
      context: ./vendor/laravel/sail/runtimes/8.0
      dockerfile: Dockerfile
      args:
        WWWGROUP: '${WWWGROUP}'
    image: sail-8.0/app
    ports:
      - '${APP_PORT:-80}:80'
    environment:
      WWWUSER: '${WWWUSER}'
      LARAVEL_SAIL: 1
    volumes:
      - '.:/var/www/html'
    networks:
      - sail
    depends_on:
      - mysql
  mysql:
    image: 'mysql:8.0'
    ports:
      - '${FORWARD_DB_PORT:-3306}:3306'
    environment:
      MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
      MYSQL_DATABASE: '${DB_DATABASE}'
      MYSQL_USER: '${DB_USERNAME}'
      MYSQL_PASSWORD: '${DB_PASSWORD}'
      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
    volumes:
      - 'sailmysql:/var/lib/mysql'
    networks:
      - sail
    healthcheck:
      test: ["CMD", "mysqladmin", "ping"]
networks:
  sail:
    driver: bridge
volumes:
  sailmysql:
    driver: local

Remember to customize the .env file and any other configuration files to match your project's needs.

By following these practices, you can create a development environment that is easy to manage, consistent across team members, and efficient when switching between different projects.

Tray2's avatar
Tray2
Best Answer
Level 73

I've used Valet for many years, but since I made a reinstall a few months ago, I decided to give Herd a try, and I'm really happy with it, I might even go Pro on it, so that I can remove DBngine.

1 like
filippocalabrese's avatar

@Tray2 Not having to deal with DB engine management is one of my absolute favourite aspects. On top of that, having to manage several legacy projects that I am slowly upgrading, managing the node and PHP versions from the host operating system turns into a lot of meta-work that only brings headaches.

Please or to participate in this conversation.