Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Yii2 Gii Laravel Package

yiisoft/yii2-gii

Gii is Yii2’s web-based code generator. Rapidly scaffold models, CRUD, controllers, forms, and modules with templates you can customize. Speeds up development and enforces consistent structure, with an extensible generator system for your own blueprints.

View on GitHub
Deep Wiki
Context7

Creating your own templates

Every generator has a form field Code Template that lets you choose a template to use for code generation. By default Gii only provides one template default but you can create your own templates that are adjusted to your needs.

If you open the folder [@app](https://github.com/app)\vendor\yiisoft\yii2-gii\generators, you'll see six folders of generators.

+ controller
- crud
    + default
+ extension
+ form
+ model
+ module

These names are the generator names. If you open any of these folders, you can see the folder default, which name is the name of the template.

Copy the folder [@app](https://github.com/app)\vendor\yiisoft\yii2-gii\generators\crud\default to another location, for example [@app](https://github.com/app)\myTemplates\crud\. Now open this folder and modify any template to fit your desires, for example, add errorSummary in views\_form.php:

<?php
//...
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-form">

    <?= "<?php " ?>$form = ActiveForm::begin(); ?>
    <?= "<?=" ?> $form->errorSummary($model) ?> <!-- ADDED HERE -->
//...

Now you need to tell Gii about our template. The setting is made in the config file:

// config/web.php for basic app
// ...
if (YII_ENV_DEV) {    
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',      
        'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20', '172.16.0.0/12'],  
        'generators' => [ //here
            'crud' => [ // generator name
                'class' => 'yii\gii\generators\crud\Generator', // generator class
                'templates' => [ //setting for out templates
                    'myCrud' => '[@app](https://github.com/app)/myTemplates/crud/default', // template name => path to template
                ]
            ]
        ],
    ];
}

Open the CRUD generator and you will see that in the field Code Template of form appeared own template.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle