Migrate does not work - chapter 2


In the chapter 2 of the book "Web Application Development with Yii 2 and PHP", there is command

$ ./yii migrate/create init_customer_table

to migrate. I have applied this command but it does not work. Rather it shows the error:

bash: ./yii: No such file or directory

I have tried to use the command

yii migrate

it gives me the error:

No command 'yii' found, did you mean:

 Command 'yi' from package 'yi' (universe)

 Command 'yri' from package 'yard' (universe)

 Command 'ii' from package 'ii' (universe)

yii: command not found

Can you tell me where I am doing wrong. I am using ubuntu 14.04.

Thanks in advance.

Thanks for posting… I thought it was just me. I’m at the same point but may be having a different issue. I wasn’t sure how to add a db to a Vagrant host and I didn’t want to risk sorting out multiple local host, so I put my database up at fatcow and assumed that would be ok, but now I’m getting this same error of no such file or directory. So no solution yet, but maybe a collective effort!

this appears to have to do with what is being loaded in environmental variables, once I pointed my path to make sure it could see the yii file it’s loading the commands.

and if you’re on a windows machine it’s better to drop the .

so just

    /yii migrate/create init_customer_table

I’ve been coming back to this several times over the last week… I’ll try a few different articles and tutorials, just trying to immerse myself in Yii2 as quickly as I can and get enough perspective to jump this hurdle. One of my earliest hunches in the difference in his bare bones examples and the advance template, is he never calls init. I’ve never seen anyone call it for the basic either, but I’ve been trying to replace his example with the basic installation, just to see if I could complete the migrations and finish the chapter on ORM… well, I was noticing this line in the index he never calls,

require(DIR . ‘/…/vendor/autoload.php’); so I looked to see what’s it auto loading! It does have an init, but that’s for composer…

I’ll try it again, if not I’m just gonna keep trying with the standard template, he’s just dissecting it to it’s bare bones anyways.

… nevermind, while that did allow the yii commands to be seen, the migrations are loading in a much deeper directory and that tends to open up another can of worms.

I would kindly point out that it’s clearly stated in the preface to the book that working knowledge of bash is required for this book, as nothing will be explained about commandline examples for brevity.

If bash tells you that "./yii" is not found then it means that you are calling it from wrong directory.

If you’ll follow the instructions in the book, then yii entry point will be in the root of your codebase so if you cd to it you’ll run the migrations just fine.

TurtleWolf, if you’d collect your problems in one place and explain clearly what you tried and what you get instead of the expected result it’ll be a lot easier to answer you.

Vagrant box is just another virtual machine. If you don’t know how to install a RDBMS into a virtual machine, learn about it first or just do not use Vagrant at all, it was used as a simplest possible way to get a would-be remote machine for experiments.