1. Go to this page and download the library: Download yii2tech/admin 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/ */
yii2tech / admin example snippets
namespace app\controllers;
use yii\web\Controller;
class ItemController extends Controller
{
public function actions()
{
return [
'index' => [
'class' => \yii2tech\admin\actions\Index::class,
'newSearchModel' => function () {
return new ItemSearch();
},
],
'view' => [
'class' => \yii2tech\admin\actions\View::class,
],
'create' => [
'class' => \yii2tech\admin\actions\Create::class,
],
'update' => [
'class' => \yii2tech\admin\actions\Update::class,
],
'delete' => [
'class' => \yii2tech\admin\actions\Delete::class,
],
];
}
public function findModel($id)
{
if (($model = Item::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
public function newModel()
{
return new Item();
}
}