Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not open input file: yii

Tags:

php

yii

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_table

I'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...

like image 997
Goat Avatar asked Jul 02 '15 06:07

Goat


2 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 serve

OUTPUT

Server started on http://localhost:8080
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: http://www.yiiframework.com/forum/index.php/topic/68728-php-yii-serve/

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:8000

Hope this helps.

UPDATE FOR ADVANCED TEMPLATE

After installing Composer and Yii, open your Advanced template folder in CLI and run this command:

  $ php ./init

This 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:

  1. http://www.yiiframework.com/wiki/799/yii2-app-advanced-on-single-domain-apache-nginx/

  2. http://www.yiiframework.com/doc-2.0/guide-start-installation.html

like image 151
ColinWa Avatar answered Oct 09 '22 22:10

ColinWa


Make you that your Environment Variables are set up correctly.

Check out these links:

Similar question

Environment Variables

Relevant parts from links:

To access the environment variables right click the My Computer icon then choose properties. Select the Advanced tab and then click Environment Variables.

window you should see

path :=>...;D:\YOURPATH\xampp\php;D:\YOURPATH\xampp\yii\yiiframework;

like image 36
Kolgrim Avatar answered Oct 09 '22 21:10

Kolgrim