PHP Classes

How to Use a PHP CRUD Template Generator to Create Twig Template Files to Manipulate Yii2 Model Class Objects Using the Package Yii2 Giitwig: Implement CRUD applications using Twig templates

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-06-29 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 11 All time: 11,388 This week: 59Up
Version License PHP version Categories
yii2-giitwig 1.0MIT/X Consortium ...5PHP 5, Libraries, Code Generation, De...
Description 

Author

This package can be used to implement CRUD applications using Twig templates.

It provides a generator class to generate templates in Twig format for CRUD applications implemented with the Yii2 framework model classes.

The configuration of the templates to generate needs to be added to the composer.json file of your project.

Innovation Award
PHP Programming Innovation award nominee
June 2024
Number 6
Twig is a PHP template engine that uses a template format inspired by the template format supported by Python frameworks like Django and Jinja.

In PHP Twig templates are used by applications developed using the Symfony framework.

This package can generate templates in Twig format that can be used to implement CRUD applications using the Yii2 framework.

Manuel Lemos
Picture of Insolita
  Performance   Level  
Name: Insolita <contact>
Classes: 24 packages by
Country: Russian Federation Russian Federation
Age: 38
All time rank: 330890 in Russian Federation Russian Federation
Week rank: 158 Up6 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 17x

Example

<?php
/* @var $this yii\web\View */
/* @var $form yii\widgets\ActiveForm */
/* @var $generator insolita\giitwig\crud\Generator */

echo $form->field($generator, 'modelClass');
echo
$form->field($generator, 'searchModelClass');
echo
$form->field($generator, 'controllerClass');
echo
$form->field($generator, 'viewPath');
echo
$form->field($generator, 'baseControllerClass');
echo
$form->field($generator, 'indexWidgetType')->dropDownList([
   
'grid' => 'GridView',
   
'list' => 'ListView',
]);
//echo $form->field($generator, 'enableI18N')->checkbox();
echo $form->field($generator, 'messageCategory');


Details

Gii Twig -Crud

Gii Twig Template Generator (Port default yii2-gii templates) (Without i18N support yet)

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist insolita/yii2-giitwig "*"

or add

"insolita/yii2-giitwig": "*"

to the require section of your composer.json file.

Usage

Twig settings

'view'=>[
            'class'=>'yii\web\View',
            'renderers'=>[
                'twig' => [
                    'class' => 'yii\twig\ViewRenderer',
                    'cachePath' => '@runtime/Twig/cache',
                    'options' => [
                        'auto_reload' => true,
                    ],
                    'globals' => ['html' => '\yii\helpers\Html','arhelp'=>'\yii\helpers\ArrayHelper','url'=>'yii\helpers\Url'],
                    'uses' => ['yii\bootstrap'],],
            ]

]

Gii settings

$config['modules']['gii'] = [
        'class'=>'yii\gii\Module',
        'generators' => [
            'twigcrud' => [
                'class' => 'insolita\giitwig\crud\Generator', // generator class
                'templates' => [
                    'twigCrud' => '@insolita/giitwig/crud/default',
                ]
            ]
        ],
    ];

for customize - copy files from @insolita/giitwig/crud/default to any place, customize and add

$config['modules']['gii'] = [
        'class'=>'yii\gii\Module',
        'generators' => [
            'twigcrud' => [
                'class' => 'insolita\giitwig\crud\Generator', // generator class
                'templates' => [
                    'twigCrud' => '@insolita/giitwig/crud/default',
                    'twigcustomCrud' => '@your/path/to/crud/customized',
                ]
            ]
        ],
    ];

  Files folder image Files (13)  
File Role Description
Files folder imagecrud (2 files, 1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (13)  /  crud  
File Role Description
Files folder imagedefault (2 files, 1 directory)
  Accessible without login Plain text file form.php Example Example script
  Plain text file Generator.php Class Class source

  Files folder image Files (13)  /  crud  /  default  
File Role Description
Files folder imageviews (7 files)
  Accessible without login Plain text file controller.php Example Example script
  Accessible without login Plain text file search.php Example Example script

  Files folder image Files (13)  /  crud  /  default  /  views  
File Role Description
  Accessible without login Plain text file create.php Example Example script
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file update.php Example Example script
  Accessible without login Plain text file view.php Example Example script
  Accessible without login Plain text file _form.php Example Example script
  Accessible without login Plain text file _listviewitems.php Example Example script
  Accessible without login Plain text file _search.php Example Example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:11
This week:0
All time:11,388
This week:59Up