I am using yii 2 basic application template. I have a VPS server and have hosted. Everything is working fine. I am using RBAC for Authorization of users. It is also working fine. Now I want to run the command yii rbac/init using putty on my server. When I do that, it gives me foll error.’
]$ yii rbac/init
-bash: yii: command not found
How should I resolve this error?
February 20, 2019, 10:23am
You need to use
./yii rbac/init and make
yii executable first using
chmod +x yii
I used php yii rbac/init, and it got executed successfully,
February 20, 2019, 10:37am
To further your understanding, about executing shell commands:
yii script is a PHP script, so you can invoke the php binary like you did to execute it,
That particular script ships with a “shebang”:
#!/usr/bin/env php <- This line
* Yii console bootstrap file.
It’s an indication for the shell you’re using, so that it knows how to execute that file.
That allow you to do :
sh yii to have it executed through the PHP binary found in your environment.
And finally, if you make that file executable (chmod +x) then you can call
./yii instead of
sh yii to execute it.
Hope this will clear some confusion