0

I am new one for the YII2.0,i like to create a model for the database via GII, but its throw an error like "table does not exist".

Below attached the screen for your further reference

click the link to view screen shot

Insane Skull
  • 9,220
  • 9
  • 44
  • 63
sen
  • 129
  • 5
  • 13
  • 4
    It says below that "There is no application component named db". Have you checked that the database is configured properly? Take a look in yii config and configure it properly, gii relies on the db connection. – chris--- Feb 11 '16 at 09:52
  • please configure your database in `config->db.php` file for yii2 basic – vishuB Feb 11 '16 at 10:07
  • @ScaisEdge Missing `'db' => require(__DIR__ . '/db.php'),` in configuration. – Insane Skull Feb 11 '16 at 11:04
  • Check if localhost/mywebsite/requirements.php looks ok –  Feb 11 '16 at 11:34

1 Answers1

1

Configure properly the basic/config/db.php eg: like this template

<?php

    return [
       'class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=yourHostName;dbname=yourDBName',
        'username' => 'yourUserName',
        'password' => 'yourPassword',
        'charset' => 'utf8',
     ];

check in your web.php for this

$config = [
  'id' => 'basic',
  'basePath' => dirname(__DIR__),
  'bootstrap' => ['log'],
  'components' => [
      ....
      'db' => require(__DIR__ . '/db.php'),
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
  • My configuration is also like above code, do you have any other idea to fix the above mentioned issue – sen Feb 11 '16 at 10:53
  • its default configuration, its already have in YII2.0, i don't change anything on that, i include the db.php file and in my db.php file having the above db config code, do you have any other idea to solve the problem – sen Feb 11 '16 at 11:09