Skip to content

milan-miscevic/yii2crud

Repository files navigation

yii2crud

PDS Skeleton Build Status

Basic CRUD operations in the Yii2 framework.

Installation

  1. Install the module via Composer:
composer require milan-miscevic/yii2crud
  1. Enable the module in the web.php config file:
'bootstrap' => [
    // ...
    'yii2crud',
],
  1. In the same file as above, define entities and namespaces for CRUD:
'modules' => [
    // ...
    'yii2crud' => [
        'class' => \mmm\yii2crud\Module::class,
        'cruds' => [
            'article',
        ],
        'namespaces' => [
            'form' => 'app\form',
            'models' => 'app\models',
            'service' => 'app\service',
        ],
    ],
],
  1. Create form and active record files:
// form/ArticleForm.php

namespace app\form;

use mmm\yii2crud\CrudForm;

class ArticleForm extends CrudForm
{
    public $title;
    public $content;

    public function rules()
    {
        return [
            [['title', 'content'], 'required'],
        ];
    }
}
// models/Article.php

namespace app\models;

use mmm\yii2crud\CrudActiveRecord;

class Article extends CrudActiveRecord
{
}

About

Basic CRUD operations in the Yii2 framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages