Mastering the Laravel Installer: Why and How to Use composer global require laravel/installer
When starting a new Laravel project, many developers immediately type:
composer create-project laravel/laravel myapp
That command works perfectly fine, but if you build Laravel applications often, you’ll quickly realize there’s a faster and more elegant way to do it. That’s where the Laravel Installer comes into play.
In this article, we’ll explore what the Laravel Installer is, why you should install it globally, and some important considerations that many developers overlook.
What is the Laravel Installer?
The Laravel Installer is a command-line utility created by the Laravel team. Instead of relying solely on Composer to create projects, it gives you the laravel
command, making your workflow smoother and faster.
For example, with the installer, creating a new project becomes as simple as:
laravel new myapp
This feels cleaner and more natural compared to the longer Composer command.
Installing the Laravel Installer Globally
To get started, you run this command:
composer global require laravel/installer
Let’s break it down:
composer
→ PHP’s package manager (likenpm
for Node.js).global
→ Installs the package in your global Composer directory, not just inside a specific project.require
→ Means you’re pulling a new dependency.laravel/installer
→ The package that gives you thelaravel
command.
After installation, the binary will be placed in your Composer global vendor/bin
directory (for example: ~/.composer/vendor/bin
or ~/.config/composer/vendor/bin
).
Making the laravel
Command Available Everywhere
One common frustration after installation is typing laravel
and seeing:
command not found
This happens because your system doesn’t yet know where to look for the global Composer binaries. To fix this, you need to add Composer’s global bin directory to your system PATH.
For example:
- Windows:
Add%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
to your system’s PATH environment variable.
Linux / macOS (bash/zsh):
Add this to ~/.bashrc
or ~/.zshrc
:
export PATH="$HOME/.composer/vendor/bin:$PATH"
or (depending on your Composer version):
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
Once done, restart your terminal and you can now run:
laravel
Benefits of Using the Laravel Installer
Here’s why the Laravel Installer is often preferred:
- Speed → It uses cached files when available, so creating new projects is much faster.
- Simplicity →
laravel new myapp
is shorter and cleaner. - Consistency → Always pulls the latest stable release by default.
- Optional presets → The installer can sometimes provide extra features, like Jetstream or Breeze scaffolding.
- Professional workflow → If you create multiple projects weekly, this tool saves time and makes your process consistent.
Alternative Without Installer
If you don’t want to install globally, you can still create Laravel projects with:
composer create-project laravel/laravel myapp
This method works everywhere since it relies directly on Composer. However, it’s slower and requires more typing.
Things to Consider
Before installing globally, keep these in mind:
- Composer version matters → Make sure you’re running a modern version of Composer (
composer --version
) to avoid path or permission issues. - Path conflicts → On shared servers or environments, global Composer paths may not be set by default. Adjust PATH accordingly.
Updating the installer → Over time, you may need to update it:
composer global update laravel/installer
Version pinning → If you want a specific Laravel version, you can specify it:
laravel new myapp --dev
or
composer create-project laravel/laravel="10.*" myapp
Finally
Using composer global require laravel/installer
is more than just a convenience. It’s about building a professional workflow that saves time, reduces errors, and makes you feel more productive.
If you’re serious about working with Laravel regularly, the installer should be part of your toolbox. Just remember to configure your PATH correctly and occasionally update the installer to stay aligned with the latest Laravel releases.
With this in place, the next time you want to spin up a fresh Laravel project, it’s just:
laravel new projectname
Fast, clean, and efficient.
Comments ()