Yii PHP Framework
Gii
Gii can generate models for you. If you want to generate a model for all database tables, enter *
for the database name.
useful extensions
- Yii2 Migration Creator – automatically create migrations from existing database
widgets
useful helpers
- ArrayHelper
Snippets
Select2 with values from DB table
<?php use yii\helpers\ArrayHelper; use kartik\select2\Select2; use app\models\YourModelYouWantToQuery; ?> … <?= $form->field($model, 'servicelevel_id')->widget(Select2::classname(), [ 'data' => ArrayHelper::map(YourModelYouWantToQuery::find()->all(),'servicelevel_id','servicelevel_id'), 'options' => ['placeholder' => 'Select a service level …'], 'pluginOptions' => [ 'allowClear' => true ], ]) ?>
input type with Html helper class
<?= Html::activeInput('number', $model, 'attribute', ['class' => 'form-control small-width', 'step' => '0.1', 'min' => '0', 'value' => $value]) ?>
always copy current vendor asset files in public dir
- AssetBundle
/** * @var array */ public $publishOptions = [ 'forceCopy' => true ];
further reading
- awesome-yii – curated list of Yii2 resources
- Yii Gist – Yii framework and extension/package catalog
Documentation / Tutorials
- Yii2 Lessons (YouTube / DoingITeasy)
- How to Program With Yii2 (envato tuts+)