# Running Laravel Wave with Sail: A Step-by-Step Guide

By Bobby Iliev, 2023-12-26. https://bobbyiliev.com/post/running-laravel-wave-with-sail-a-step-by-step-guide/

## Introduction

This tutorial will guide you through the process of running Laravel Wave using Laravel Sail, a light-weight command-line interface for managing Dockerized Laravel applications. This tutorial is perfect for those who prefer a Docker-based environment for their Laravel applications. Let's dive in!

## Prerequisites

Before we begin, ensure you have:

 - PHP 8.1 
 -  Composer installed on your system

These are essential for running any Laravel application.

## Getting Started with Laravel Wave

First things first, let's get the Laravel Wave repository. Fork and clone the repository from GitHub:

```bash
git clone git@github.com:thedevdojo/wave.git
```

> Note: if you've cloned the repository change `thedevdojo` with your GitHub username

Cloning the repository provides you with the necessary files to get started.

## Setting Up Laravel Sail

Laravel Sail is a simple solution for running your Laravel project using Docker. Under the hood, it uses [Docker Compose](https://devops-daily.com/guides/introduction-to-docker/08-docker-compose). Follow these steps to set it up:

### Install Dependencies

Navigate to your project directory and install the Composer dependencies:

```bash
composer install
```

This command pulls in all the necessary PHP packages required by Laravel Wave.

### Environment Configuration

Next, you need to set up your environment file. Copy the `.env.example` file to create your `.env` file:

```bash
cp .env.example .env
```

After copying the file, update the database details in your `.env` file to match the following:

```bash
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=wave
DB_USERNAME=sail
DB_PASSWORD=password
```

These settings configure your application to connect to the MySQL database provided by Sail.

### Start Sail

Now, it's time to start your Dockerized environment with Sail:

```bash
bash ./vendor/bin/sail up -d
```

This command starts all the necessary Docker containers in the background.

### Database Migrations and Seeding

With your environment up and running, proceed to set up your database:

```bash
./vendor/bin/sail artisan migrate 
./vendor/bin/sail artisan db:seed
./vendor/bin/sail artisan storage:link
```

These commands create the necessary database tables, seed them with data, and set up storage links.

## Accessing Your Application

Finally, after completing the setup, you can access your Laravel Wave application by visiting `http://localhost` in your browser.

## Conclusion

Setting up Laravel Wave with Sail offers a seamless and straightforward way to manage your local Laravel Wave dev app in a Docker environment. This approach not only simplifies the development process but also ensures consistency across different development environments.

For production, I could suggest using DigitalOcean. If you wish, you can use my affiliate code to get [free $200 DigitalOcean credit](https://m.do.co/c/2a9bba940f39) to spin up your own servers!

Happy coding, and as always, feel free to reach out if you have any questions or need further assistance!
