How to install Laravel

Dr. Adam Nielsen
2 min readOct 12, 2023

From the Laravel installation docs, you may find yourself here:

When you try to install this project using your local PHP version, you may run into issues, because the config of your PHP is not correct on your PC.

You can avoid this, by creating a container with the correct PHP version and setting to install your Laravel application.

Use Docker

curl -s https://laravel.build/example-app | bash

or if you want to build a specific version, you can tag it like this:

curl -s https://laravel.build/example-app | bash -s -- --version="^9"

This will download Laravel, install composer dependecies and setup sail directly for you.

Now it just remains to cd into the folder and start:

./vendor/bin/sail up

For other computers

If you later want to install your application on a different system, you would clone the repository. You would need to have PHP and composer on that machine, to install your vendor files, including sail. That’s a hen and egg issue. To avoid it, you can again use docker to install your vendor files like

docker run --rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/var/www/html" \
-w /var/www/html \
laravelsail/php82-composer:latest \
composer install --ignore-platform-reqs

and now you can once again just use sail

--

--