Originally published on php-apps.learnio.dev — part of the Using Native PHP course. View this lesson on the original site.

Choosing the Right Development Environment

Selecting the appropriate development environment is essential for effective development with Laravel. In this lesson, we will compare two popular options: Laravel Herd and a manual PHP installation, highlighting their advantages and disadvantages to help you make an informed choice.

Overview of Laravel Herd

Laravel Herd is a local development environment specifically designed for Laravel applications. It streamlines the setup process by providing a pre-configured stack that includes PHP, MySQL, and other essential services. Here’s how to get started with Laravel Herd:

  1. Install Laravel Herd: Download it from the official website and follow the installation instructions.
  2. Create a New Project: Once installed, create a new Laravel project with the command:
    herd new my-project
    
  3. Start the Development Server: Navigate to your project directory and run:
    herd up
    

This command starts your local development server with all necessary services running.

Overview of Manual PHP Installation

A manual PHP installation offers greater control over your environment. Here’s a step-by-step guide to installing PHP manually:

  1. Update Package Index: Ensure your package index is up to date:
    sudo apt-get update
    
  2. Install PHP: Install PHP along with necessary extensions:
    sudo apt-get install php php-mysql php-xml php-mbstring
    
  3. Verify Installation: Check your PHP installation with:
    php -v
    

Comparing Both Approaches

Feature Laravel Herd Manual PHP Installation
Ease of Setup Very easy, one-click installation Requires multiple steps
Control Limited control over configuration Full control over versions and settings
Resource Management Automatically manages resources Requires manual management
Ideal For Beginners and quick setups Advanced users needing custom setups

See it with a Workflow Diagram

flowchart TD
    A[Start] --> B{Choose Environment}
    B -->|Laravel Herd| C[Install Laravel Herd]
    B -->|Manual PHP| D[Install PHP Manually]
    C --> E[Create Project]
    D --> F[Create Project]
    E --> G[Start Server]
    F --> H[Start Server]
    G --> I[Development Ready]
    H --> I

Try it with Runnable Commands

To see both methods in action, let’s create a simple Laravel project using both approaches:

Using Laravel Herd

herd new my-laravel-app
cd my-laravel-app
herd up

Using Manual PHP Installation

sudo apt-get update
sudo apt-get install php php-mysql php-xml php-mbstring
composer create-project --prefer-dist laravel/laravel my-laravel-app
cd my-laravel-app
php artisan serve

If it Goes Wrong

If you encounter issues with Laravel Herd, ensure that your system meets the requirements and that you have the latest version installed. For manual installations, verify that all dependencies are correctly installed and that your PHP version is compatible with Laravel.

Remember

Choosing between Laravel Herd and a manual PHP installation depends on your specific needs. If you prefer simplicity and speed, Laravel Herd is an excellent choice. However, if you need fine-tuned control over your environment, a manual installation may be the way to go.

From Using Native PHP — Environment setup and development workflow