- macOS
- Docker Desktop
-
Download Docker Desktop: Download Docker Desktop from Docker's official website and install it.
-
Run Docker Desktop: Open Docker Desktop and ensure it is running.
-
Verify Docker Installation: Open Terminal and run the following command to verify the installation:
docker --version
-
Install Homebrew: If Homebrew is not already installed, install it by running the following command in Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install PHP: Use Homebrew to install PHP:
brew install php
-
Install Composer: If Composer is not already installed, run the following commands:
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
-
Create a New Laravel Project: Create a new Laravel project using Composer:
composer create-project laravel/laravel example-app cd example-app
-
Install Laravel Sail: Require Laravel Sail as a development dependency:
composer require laravel/sail --dev
-
Publish Sail's Docker Configuration: Publish Sail's Docker configuration:
php artisan sail:install
-
Start Docker Containers: Start the Docker containers:
./vendor/bin/sail up
-
Copy Environment File: Copy the
.env.example
file to.env
:cp .env.example .env
-
Generate Application Key: Generate a new application key:
./vendor/bin/sail artisan key:generate
-
Update Environment Variables: Update the
.env
file with the necessary database configuration if needed.
- Open Browser:
Open your browser and navigate to
http://localhost
. You should see the Laravel welcome page.
-
Stop Docker Containers:
./vendor/bin/sail down
-
Run Artisan Commands: To run other Artisan commands, prefix them with Sail:
./vendor/bin/sail artisan migrate
If you encounter any issues, ensure:
- Docker Desktop is running.
- The macOS environment is properly configured.
By following these steps, you should have a fully functional Laravel Sail and Docker environment set up on your macOS machine.