Laravel Console Aliases on Windows

    I just read an article on Laravel News about Laravel bash aliases but they all assumed that every developer uses a Linux box or a Mac. Truth be told, many developers do use the Windows operating system as their main or even only development environment. I am one of them.

    First, a console/bash alias is a pseudo-name like a nickname but for a command. All developers using the Laravel PHP framework have had to endure using the ‘long’ commands like ‘php artisan migrate:refresh’. This is not a Laravel problem only but with many commands you may normally use such as Git commands to fix merge conflicts or resetting your project to a previous state.

    So how do we create a console alias in Windows you ask? The quickest way is to take advantage of a command called Doskey from Doskey.exe. These application enables you to create a macro that is accessible globally on the command prompt with the given name.

    Examples of common Laravel aliases

    doskey pa=php artisan
    Creating an alias for php artisan
    using the pa command we created

    Running pa command alias runs exactly like php artisan command

    Now you must be asking yourself, “Why didn’t I do this before?”. You now have a solution to all your console typing woes. Make all your command aliases using this scheme:

    doskey [alias]=[command]

    Replace [alias] with the name of your command and [command] with the actual command including arguments you want to replace. Here are some of my aliases listed using doskey /m:

    doskey /m
    List all custom commands made with doskey

    Click here to visit Laravel News if you want to learn the Bash way of creating aliases.