Why I Wanted a Shorter Laravel Command
If you use Laravel every day, you type the same command again and again:
php artisan ...
For example:
php artisan optimize
php artisan migrate
php artisan make:model User
After typing this dozens of times per day, it becomes slow and annoying.
So I decided to make my workflow faster. My goal was simple:
Use just one letter — “a” — instead of “php artisan”.
Why a Normal Alias Does Not Work in Windows PowerShell
Windows PowerShell does not support this kind of alias correctly.
If you try to create a simple alias, you will see errors like:
Could not open input file: optimize
This happens because PowerShell incorrectly runs:
php optimize
instead of:
php artisan optimize
To fix this, we need a function that sends all arguments directly to php artisan.
Step-by-Step: Create the “a” Command in PowerShell
Follow these steps to make your custom a command work everywhere.
1. Open PowerShell
Press Start → PowerShell.
2. Check Your Profile File Path
Run:
echo $PROFILE
You will see something like:
C:\Users\YourName\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
3. Open the Profile File
Run:
notepad $PROFILE
If the file does not exist, choose Yes to create it.
4. Add This Function Inside the File
This is the correct function that makes a work exactly like php artisan:
function a {
& php .\artisan @args
}
This line:
- runs
php artisan - passes all arguments to it (
@args) - works in any Laravel project folder
- supports all Artisan commands normally
Save the file and close Notepad.
5. Reload the Profile
Run:
. $PROFILE
(important: dot, space, then $PROFILE)
Your new command is now active.
How to Use the New “a” Command
Now you can replace anything like this:
php artisan optimize
with:
a optimize
More examples:
a migrate
a tinker
a config:cache
a make:model Product
a make:controller Admin/DashboardController
It behaves 100% the same as:
php artisan ...
but much faster to type.
Why This Saves Time
If you run multiple Artisan commands during development, this simple shortcut:
- saves keystrokes
- speeds up your workflow
- makes repetitive tasks easier
- keeps your hands on the keyboard
- reduces typing effort
It takes less than one minute to set up but improves your daily coding speed immediately.
See my blog post: https://eddie-goldman.com/how-to-replace-php-artisan-with-a-short-command-in-windows-powershell/
Top comments (0)