Modules is replacement of folder structure in yii2 .Meaning no folder structure in controllers folder Details…
Category: yii
Random with Yii2
##for gridview widget #conroller
1 2 3 4 5 6 7 8 9 10 11 12 |
public function actionIndex() { $data = [ ['id' => 1, 'name' => 'name 1'], ['id' => 2, 'name' => 'name 2'], ['id' => 100, 'name' => 'name 100'], ]; $dataProvider = new ArrayDataProvider([ 'allModels' => $data]); return $this->render('index', array('dataProvider' => $dataProvider)); } |
and #view
1 2 3 4 5 6 |
<?php use yii\grid\GridView; echo GridView::widget([ 'dataProvider' => $dataProvider, ]); ?> |
Component in yii 2
Step1:Make a folder named “components” in your project root folder. step2: write your custom component Details…
Create a Simple to Complex Widget in Yii
First create a folder named “components” in the project root directory. Now create one class Details…
Working with Database in Yii2
Create a database yiibasic #database
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
CREATE TABLE IF NOT EXISTS `employees` ( `Id` int(11) NOT NULL, `first_name` text NOT NULL, `last_name` text NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `employees` -- INSERT INTO `employees` (`Id`, `first_name`, `last_name`) VALUES (1, 'aaaa', 'cccc'), (2, 'ssss', 'cccc'); select * from employees; |
create a model
Role Based Authentication in Yii
http://www.javatpoint.com/what-is-yii composer global require “fxp/composer-asset-plugin:^1.2.0” yii migrate In case of yii2-app-base template, from which I Details…