The database must contain at less the following two tables: ~~~ CREATE TABLE user ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, .. .. ); CREATE TABLE message ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, sender_id BIGINT UNSIGNED NOT NULL, receiver_id BIGINT UNSIGNED NOT NULL, text VARCHAR(1000) NOT NULL is_new BOOLEAN DEFAULT 1, is_deleted_by_sender BOOLEAN DEFAULT 0, is_deleted_by_receiver BOOLEAN DEFAULT 0, created_at DATETIME NOT NULL, CONSTRAINT fk_message_sender_id FOREIGN KEY (id) REFERENCES user (id) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT fk_message_receiver_id FOREIGN KEY (id) REFERENCES user (id) ON DELETE NO ACTION ON UPDATE CASCADE, ); ~~~ The user table stores users, and the message table stores messages
Since: 1.0
Author: Buba Suma (bubasuma@gmail.com)
Inheritance: extends yii\base\Module, implements yii\base\BootstrapInterface
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (!strcmp($action->id, 'start') || !strcmp($action->id, 'stop')) {
             $this->module->initDemo();
             $this->module->controllerMap['migrate'] = ['class' => 'bubasuma\\simplechat\\console\\MigrateController', 'migrationPath' => $this->migrationPath];
         }
         $this->stdout("Yii2 SimpleChat Demo\n\n", Console::BOLD);
         return true;
     } else {
         return false;
     }
 }
 /**
  * @inheritDoc
  */
 public function init()
 {
     parent::init();
     $this->module->initDemo();
     $this->user = User::findOne(['id' => \Yii::$app->request->get('userId')]);
 }