No index.php file in yii2 basic and yii migration error


(jamess07) #1

I’m a beginner and really struggling to get an existing yii2 project running on localhost. As far as I can see, there’s no index.php file, but all my online searches say that only happens with the advanced framework (I don’t see any backend or frontend folders that come with the advanced framework in my project though?).

I’ve followed all the instructions in the project’s readme file and it installed the vendor folder, but is giving me an exception when I type in the yii migrate command. It installed 13 of the 47 migrations without problem but then gets stuck on this:

*** applying m170317_154007_current_date

Exception ‘ReflectionException’ with message ‘Class m170317_154007_current_date does not exist’

in C:\xampp\htdocs\Duals\vendor\yiisoft\yii2\di\Container.php:428

$reflection = new ReflectionClass($class);
Stack Trace: 
#0 C:\xampp\htdocs\Duals\vendor\yiisoft\yii2\di\Container.php(428): ReflectionClass->__construct('m170317_154007_...')
#1 C:\xampp\htdocs\Duals\vendor\yiisoft\yii2\di\Container.php(364): yii\di\Container->getDependencies('m170317_154007_...')

So basically a two part question

  1. This is all existing code from a working site, how do I fix this?
  2. Will this create the index.php file at the end, and if not, am I just missing something simple as a beginner or is the installation just really complicated sometimes?

Thanks & Regards

Ask For Email Help


(Mehdi Achour) #2

It seems that you’re running the basic app template. You should have a script named init at the root of the project. Run it using ./init, pick “development” mode and it will generate web/index.php & config/*-local.php for you.

(This files are not meant to be in VCS, so it’s normal that they are missing in your checkout. You can tweak them locally, enable debug, etc without risking of accidentally pushing this changes to prod)

As for the migration, the problem seems to be with autoloading a particular migration. Are you able to locate the file named m170317_154007_current_date.php in your installation ?