Could not open input file: yii
Matthew Barrera
I'm working with Yii2 and trying to init some migration files. This was working a few months ago, now I'm getting the following error
'yii' is not recognized as an internal or external command
command I'm trying to run is 'yii migrate/create init_my_tableI've been looking around but not exactly sure what the problem is.
Seems like this should be a pretty generic and easy to fix error...
3 Answers
Before i delve into proposing a solution, check if you installed Yii's Basic Template or the Advanced Template.
$ php yii serve
will work for the "basic" template.
Make sure at the Terminal, you have changed to the "basic" directory, then enter the command:
$ php yii serveOUTPUT
Server started on
Document root is "PATH/public_html/yiiproject/basic/web"
Quit the server with CTRL-C or COMMAND-C.IF you are using the Advanced Template, read this thread and see if the Thread here helps. Read it till the very end:
Had this same issue but was using the Advanced template.
php yii serve Could not open input file: yii
i tried this command as recommended. It worked:
$ php -S localhost:8000Hope this helps.
UPDATE FOR ADVANCED TEMPLATE
After installing Composer and Yii, open your Advanced template folder in CLI and run this command:
$ php ./initThis initialization process will setup the project and create necessary files.
Set your document root properly in apache to your /advanced/web/
More Reading to run your project:
Make you that your Environment Variables are set up correctly.
Check out these links:
Relevant parts from links:
1To access the environment variables right click the My Computer icon then choose properties. Select the Advanced tab and then click Environment Variables.
path :=>...;D:\YOURPATH\xampp\php;D:\YOURPATH\xampp\yii\yiiframework;
Try installing composer globally. I had similar issue but it was resolved after I installed composer via installation file and using my environment variables, I made available globally.
1