How to install Laravel 8 on Mac

Install laravel 8 on mac os

If you're developing laravel project on a Mac and Docker Desktop is already installed, you can open your terminal and type following commands to create a new Laravel 8 project.

# if you want to name your project differently
# change laravel8-app to something else
curl -s "https://laravel.build/laravel8-app" | bash​

Once above command runs successfully you will see output like following image:

Run your newly installed laravel 8 app

With your newly installed laravel 8 project and using docker you are now able to run your laravel 8 project inside docker environment. After the project has been created, you can navigate to the application directory and start Laravel Sail.

Laravel Sail provides a simple command-line interface for interacting with Laravel's default Docker configuration: Open your terminal window while being in laravel project root directory and run following command to run your app:

# go to your new laravel project directory
cd laravel8-app

# run following command to run your app in background
./vendor/bin/sail up -d​

Once docker images are pulled and containers are running you will see something similar output on your console:

Go to your browser and hit: http://localhost to see your running app.

How to check running containers in Laravel 8?

Now, you know that your project is running under docker therefore you would need to learn some of the useful commands in order to interect with docker containers. First command you are going to learn that will help you show all your running container will be docker ps.

Open your terminal and type one of the following command to see all running containers:

# check all running containers
docker ps

# check all running container but in pretty format
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}\t{{.Ports}}"

Above command will show you following output:

How to check container logs in laravel 8?

To check the app container log you can run following command:

# first list all running container
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}\t{{.Ports}}"

# pick the container ID or Name you want to check logs for
# then using container id or name check the container logs using following command
docker logs -f <containerID or containerName>

Useful sails commands to interect with your Laravel 8 app running in container

As by now you know that laravel uses sails to interect with your laravel app running inside your container. You would need to learn some useful sails command in order to work with your laravel 8 project.

Followings are some of the important commands you can use:

Command Description
./vendor/bin/sail up Run your laravel 8 app inside containers
./vendor/bin/sail down Destroy your application and all running containers
./vendor/bin/sail up -d Run your containers in background or in deamon mode
./vendor/bin/sail artisan Run laravel artisan commands using sail without login to container
./vendor/bin/sail php -v Check php version running inside your container
./vendor/bin/sail npm -v Check npm version running inside your container
./vendor/bin/sail share Share your site publicly in order to preview your site for a colleague