A zsh utility function for creating Laravel apps with Sail

Last reviewed on February 29, 2024

To create a Laravel app with Sail, we run the following command in Terminal:

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

I can never remember this so I always have to find this documentation page, replace "example-app", initialize the repo, and make the first commit. To make this easier, I created a utility function.

~/.zshrc
install-laravel() {
  curl -s "https://laravel.build/$1" | bash
  git init
  git add --all
  git commit -m 'Laravel installation'
}

Now I can run:

install-laravel my-project