1. Go to this page and download the library: Download bscheshirwork/yii2-cubs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bscheshirwork / yii2-cubs example snippets
use bscheshirwork\cubs\base\CubsDefaultInterface;
use bscheshirwork\cubs\db\CubsMigrationTrait;
use yii\db\Migration;
class m170130_100000_createProjectTables extends Migration implements CubsDefaultInterface
{
use CubsMigrationTrait;
public function up()
{
$options = $this->db->driverName == 'mysql' ? 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB' : '';
$this->createTable('{{%project}}', [
'id' => $this->primaryKey(),
'name' => $this->string(64)->notNull(),
'url' => $this->text(),
'description' => $this->text(),
], $options);
$this->createIndex('{{%project_unique_name}}', '{{%project}}', 'name', true);
$this->createTable('{{%project_form}}', [
'id' => $this->primaryKey(),
'projectId' => $this->integer(),
'type' => $this->string(32)->notNull(),
'name' => $this->string(64)->null(),
'url' => $this->text(),
'description' => $this->text(),
], $options);
$this->addForeignKey('{{%fk_project_project_form}}', '{{%project_form}}', 'projectId', '{{%project}}', 'id', 'CASCADE', 'CASCADE');
}
public function down()
{
$this->dropTable('{{%project_form}}');
$this->dropTable('{{%project}}');
}
}