Create a Laravel application

There are a few different ways to get up and running with Laravel. In the past, I have had students install PHP and Composer on their machine. This works reasonably well for simple applications and for most of the topics that 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.

Laravel introduced a tool called Laravel Sail that allows developers to build Laravel applications using Docker.

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 technologies directly on our machines. 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, thanks to both Docker and Laravel Sail. Laravel Sail makes it really simple, so you don't even really need to know Docker. Just having a basic understanding of Docker will suffice.

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.

First, install Docker: https://www.docker.com/products/docker-desktop/.

Follow the instructions for your operating system. In the instructions, wherever it says "example-app", replace that with "music-app".

If you run into any issues, here are a few resources you may find helpful: