Scaffolding a Laravel Application

There are a few different ways to get up and running with Laravel.

Originally the plan was to have you install PHP and Composer on your machine and run a Laravel application that way. This is what I have done in the past, and it works reasonably well for simple applications and for the topics we cover in this class. One drawback however is that sometimes students run into issues and it can be challenging to debug since everyone has a different operating system. It also involves a bit more configuration and command line usage, which isn't ideal for those who are newer to the command line.

In the 2 months that have passed since I wrote the Welcome page, Laravel has introduced a new tool called Laravel Sail that allows developers to build Laravel applications using Docker.

So, what is Docker? Docker is a tool that makes it easy to create isolated development environments regardless of what operating system you have. This means that we can all run our Laravel applications on Linux with the same versions of PHP, Composer, MySQL, Postgres, Redis, etc without having to install those onto our machines directly. This is really powerful! We don't have to spend hours installing various technologies and configuring them. Instead, we can install Docker and spin up a development environment for Laravel applications with a single command.

If you're familiar with virtual machines, think of Docker as a tool that can help us spin up a lightweight virtual machine called a container. Think of a container as an isolated environment with its own file system that runs on top of another operating system. For example, I have a Mac, and I can use Docker to create a container for the different applications I am building. Each of these containers are completely isolated from the others.

Now that you have a basic understanding of Docker, let's set up a Laravel application using Laravel Sail, which uses Docker. Follow the instructions for your operating system. In the instructions, wherever it says "example-app", replace that with "music-app".

I believe building Laravel applications with Laravel Sail should be much simpler than how I've done it in the past. Personally, I have been using it for a side project for the past month and it has worked out very well. If you run into any issues however, please reach out to me or the TA. If for whatever reason we can't get Laravel Sail working on your computer, you can always fall back on the instructions that I provided on the Welcome page.