6

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

Skatox
  • 4,237
  • 12
  • 42
  • 47
Goat
  • 179
  • 2
  • 2
  • 11

3 Answers3

20

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

ColinWa
  • 919
  • 1
  • 10
  • 27
1

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;

Community
  • 1
  • 1
Kolgrim
  • 61
  • 5
  • Link only answers are discouraged as the link may go stale; could you include the relevant parts in this answer and keep the links as references – beresfordt Jul 02 '15 at 07:12
0

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.

matthew
  • 21
  • 3
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 27 '21 at 00:41