Search code examples
laravelpathlaravel-5.3laravel-artisan

Is it possible to add artisan to my path so I don't have to prepend artisan commands with 'php'


When I SSH into homestead, I no longer need to prepend my artisan commands with php. ie. I can write, for example

artisan -h

rather than

php artisan -h

But on my local machine, I always have to first issue the command through php. How is it that this is not necessary within homestead, and is there a way to replicate this behaviour on my local machine. I am running Windows 7.


Solution

  • The answer really depends on what OS you're running locally. On macOS / Linux, you can edit (or create) a .bash_aliases file in your user folder and add the line:

    alias artisan='php artisan'
    

    You can see this in action by running the following command in homestead:

    nano ~/.bash_aliases