-1

for our web application we use useful commands such as :

php artiasn
php artisan serve
composer update
php artisan view:clear

and now i want to make alias for them into ~/.bash_profile

alias ps ="php artisan"
alias serve="php artisan serve"
alias cu="composer update"
alias vc="php artisan view:clear"

now when i try to reload the file by using source ~/.bash_profile i get this error:

.bash_profile:1: php artisan not found

I thought i should use cd for change to the directory before. I got the error again. for example:

alias ps ="cd /User/myname/Desktop/project php artisan"
DolDurma
  • 15,753
  • 51
  • 198
  • 377
  • @DᴀʀᴛʜVᴀᴅᴇʀ you right, after successfully reload the file. when i try to use alias commands i get `zsh: command not found: vc` error – DolDurma Jan 17 '21 at 05:27
  • for Windows GitBash my issue was the single quote which copied from a webpage and I replaces the quotes with my keyboard singlequotes like - alias pa='php artisan' before it was like alias pa=’php artisan’ – Sabin Chacko Mar 10 '23 at 05:56

1 Answers1

1

If i remember correctly in the docs the space in between:

alias ps =

Should be:

alias ps=

Also instead of using source there is a shorter way with . ~/.zshrc

Per memory you have to reference where you have PHP. You can run which php to get the location if you cannot access from /usr/bin/php.

Can also try alias ps ="/usr/bin/php artisan"

DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
  • putting aliases into `~/.zshrc` file and reload it, resolved my problem. please update your post and let me to accept that – DolDurma Jan 17 '21 at 05:35
  • 1
    It might be better to use `#!/usr/bin/env php` rather than pointing to `/usr/bin/php` directly, depending on your needs. See https://stackoverflow.com/a/2429517/802469 – Reed Jan 17 '21 at 05:53