Yii2

Photo of author

fahmialazhar

Composer: Requirements could not be resolved in Yii2

Sometimes when you add more packages in yii2, you may get error like this: Problem 1 – yiisoft/yii2-jui 2.0.6 requires bower-asset/jquery-ui 1.11.*@stable -> no matching package found. – yiisoft/yii2-jui 2.0.5 requires bower-asset/jquery-ui 1.11.*@stable -> no matching package found. – yiisoft/yii2-jui 2.0.4 requires bower-asset/jquery-ui 1.11.*@stable -> no matching package found. – yiisoft/yii2-jui 2.0.3 requires bower-asset/jquery-ui 1.11.*@stable … Read more

Setting Time Zone Yii2

Bisa dilakukan dengan dua cara: edit file config/web.php, di bagian $config =[] tambahkan: ‘timeZone’ => ‘Asia/Jakarta’, atau pakai fungsi date_default_timezone_set(‘Asia/Jakarta’);

Penggunaan Yii2 Migration

Referensi: http://www.yiiframework.com/doc-2.0/guide-db-migrations.html Buka terminal, masuk ke root folder project: Ceritanya mau bikin table pegawai ketik: yii migrate/create create_pegawai_table -> akan menggenerate skeleton code di folder migrations (m160928_024257_create_pegawai_table.php) edit file: m160928_024257_create_pegawai_table.php (Referensi: http://www.yiiframework.com/doc-2.0/yii-db-schemabuildertrait.html) misal: $this->createTable(‘pegawai’, [ ‘id’ => $this->primaryKey(), ‘name’ => $this->string(64)->notNull(), ‘type’ => $this->integer()->notNull()->defaultValue(10), ‘description’ => $this->text(), ‘rule_name’ => $this->string(64), ‘data’ => $this->text(), ‘created_at’ => $this->datetime()->notNull(), ‘updated_at’ => $this->datetime(), … Read more

Enable Pretty URL Yii2

Masuk ke config/web.php Uncomment: ‘urlManager’ => [ ‘enablePrettyUrl’ => true, ‘showScriptName’ => false, ‘rules’ => [ ], ], Bikin file .htaccess RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php Save di folder web