milan-miscevic / yii2crud
This package is abandoned and no longer maintained.
No replacement package was suggested.
Basic CRUD operations in the Yii2 framework
0.18
2020-10-24 23:52 UTC
Requires
- php: ^7.2
- yiisoft/yii2: ^2.0.38
- yiisoft/yii2-bootstrap: ^2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^8
- vimeo/psalm: ^3
README
Basic CRUD operations in the Yii2 framework.
Installation
- Install the module via Composer:
composer require milan-miscevic/yii2crud
- Enable the module in the web.php config file:
'bootstrap' => [ // ... 'yii2crud', ],
- 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', ], ], ],
- 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 { }