I want to install Laravel 9 with sail, but when I execute: curl -s "https://laravel.build/example-app" | sh , the command installs Laravel 11.
Is there a command that allows me to specify which version I want to install?
A command equivalent to this: composer create-project laravel/laravel:^9.0 example-app
I tried this: curl -s "https://laravel.build/devjobs" | sh , but this command installs Laravel 11, I want to install Laravel 9.
When you access the URL https://laravel.build/example-app, you can view the bash script to install laravel. The command laravel new example-app
will install the latest laravel since that is what laravel new
does. Check this docs for reference
What you can do is either create your own bash script and change laravel new example-app
to composer create-project laravel/laravel:^9.0 example-app
OR manually run commands create-project, install sail etc.
For reference you can do the following:
Assuming that you are in linux with docker installed, create a laravel9.sh file with the following contents
docker info > /dev/null 2>&1
# Ensure that Docker is running...
if [ $? -ne 0 ]; then
echo "Docker is not running."
exit 1
fi
docker run --rm \
--pull=always \
-v "$(pwd)":/opt \
-w /opt \
laravelsail/php82-composer:latest \
bash -c "create-project laravel/laravel:^9.0 example-app --no-interaction && cd example-app && php ./artisan sail:install --with=mysql,redis,meilisearch,mailpit,selenium "
cd example-app
# Allow build with no additional services..
if [ "mysql redis meilisearch mailpit selenium" == "none" ]; then
./vendor/bin/sail build
else
./vendor/bin/sail pull mysql redis meilisearch mailpit selenium
./vendor/bin/sail build
fi
CYAN='\033[0;36m'
LIGHT_CYAN='\033[1;36m'
BOLD='\033[1m'
NC='\033[0m'
echo ""
if sudo -n true 2>/dev/null; then
sudo chown -R $USER: .
echo -e "${BOLD}Get started with:${NC} cd example-app && ./vendor/bin/sail up"
else
echo -e "${BOLD}Please provide your password so we can make some final adjustments to your application's permissions.${NC}"
echo ""
sudo chown -R $USER: .
echo ""
echo -e "${BOLD}Thank you! We hope you build something incredible. Dive in with:${NC} cd example-app && ./vendor/bin/sail up"
fi
Make your laravel9.sh file executable
chmod +x laravel9.sh
Execute laravel.sh
./laravel9.sh
This script will do the following:
If you are in windows, do what windows do to create executable files (.bat)
Or you can do the manual commands (without executable, can be done in windows too):
docker run --rm \
--pull=always \
-v "$(pwd)":/opt \
-w /opt \
laravelsail/php82-composer:latest \
bash -c "create-project laravel/laravel:^9.0 example-app --no-interaction && cd example-app && php ./artisan sail:install --with=mysql,redis,meilisearch,mailpit,selenium "
cd example-app
./vendor/bin/sail pull mysql redis meilisearch mailpit selenium
./vendor/bin/sail build
2.b If you are in linux, change ownership is needed
sudo chown -R $USER: .
./vendor/bin/sail up