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!
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:
git clone firstname.lastname@example.org:thedevdojo/wave.git
Note: if you've cloned the repository change
thedevdojowith 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. Follow these steps to set it up:
Navigate to your project directory and install the Composer dependencies:
This command pulls in all the necessary PHP packages required by Laravel Wave.
Next, you need to set up your environment file. Copy the
.env.example file to create your
cp .env.example .env
After copying the file, update the database details in your
.env file to match the following:
These settings configure your application to connect to the MySQL database provided by Sail.
Now, it's time to start your Dockerized environment with Sail:
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:
./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.
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 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!