Minor problems with installing Yii2.0 advanced templates

Source: Internet
Author: User
In the morning, the advanced version of Yii2.0 is installed using Composer. After all the configurations are completed, an error is found at the logon location. The error message shows that no corresponding user table exists, then I read it again against the official documentation on Github and found that the third step was not executed. I don't know how to do this step.

In the morning, the advanced version of Yii2.0 is installed using Composer. After all the configurations are completed, an error is found at the logon location. The error message shows that no corresponding user table exists, then I read it again against the official documentation on Github and found that the third step was not executed. I don't know how to do this step.

Reply content:

In the morning, the advanced version of Yii2.0 is installed using Composer. After all the configurations are completed, an error is found at the logon location. The error message shows that no corresponding user table exists, then I read it again against the official documentation on Github and found that the third step was not executed. I don't know how to do this step.

Step 3: perform database migration operations. Migration-related documents

  1. You should first establish a database

  2. Configure data information in the common/config/main-local.php

  3. Yii is a php script. You can run php yii migrate.
    Execute the migration script under the console/migrations directory. At the beginning of the migration, a user table is created.
    The migration script content is as follows:


  db->driverName === 'mysql') {            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';        }        $this->createTable('{{%user}}', [            'id' => Schema::TYPE_PK,            'username' => Schema::TYPE_STRING . ' NOT NULL',            'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL',            'password_hash' => Schema::TYPE_STRING . ' NOT NULL',            'password_reset_token' => Schema::TYPE_STRING,            'email' => Schema::TYPE_STRING . ' NOT NULL',            'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',            'created_at' => Schema::TYPE_INTEGER . ' NOT NULL',            'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL',        ], $tableOptions);    }    public function down()    {        $this->dropTable('{{%user}}');    }}

Based on the basic template, you can try to run the following command in the project directory:

./yii migrate

Open cmd, go to the project directory, and type

yii migrate

If you reinstall YII2, you can directly copy and generate the user table. Step 1 mainly refers to configuring database tables.

Yii advanced template Migrate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.