# webkul/code-generator

> module lets you generate models, controller, helpers in seconds so that you can focus more on application logic

`composer require webkul/code-generator`

Canonical URL: https://packagento.com/webkul/code-generator

## At a glance

- **Vendor**: webkul (https://packagento.com/webkul.md)
- **Latest version**: 2.0.8 — released 2024-05-13
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/webkul/code-generator and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require webkul/code-generator:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

module lets you generate models, controller, helpers in seconds so that you can focus more on application logic

## README

## Installation

``` composer require webkul/code-generator ```

``` php -f bin/magento setup:upgrade ```

## User Guide

- [Magento 2 Code Generator](https://webkul.com/blog/magento-2-code-generator/)

## Usage

- To create new Module

``` php bin/magento generate:code Module_Name --type=new-module  ```

- To create models

``` php bin/magento generate:code Module_Name --table="table_name" --type=model --name=ModelName ```

If you have created the db_schema file for the table in the above command, it will automatically create setter and getter of all the columns in the schema.

- To create repositories

``` php bin/magento generate:code Module_Name --type=repository --name=RepositoryClassName --model-class=ModelClassFullName --collection-class=CollectionClassFullName ```

- To create controller

``` php bin/magento generate:code Module_Name --type=controller --name=ControllerName --area=frontend|adminhtml --path=RelativeToModuleControolerFolder --router=RouteName ```

- To create helper

``` php bin/magento generate:code Module_Name --type=helper --name=HelperName  ```

- To create payment method

``` php bin/magento generate:code Module_Name --type=payment --name=MethodName --payment-code=PaymentMethodCode ```

- To create shipping method

``` php bin/magento generate:code Module_Name --type=shipping --shipping-code=custom_shipping ```

- To create Plugin

``` php bin/magento generate:code Module_Name --type=plugin --name=PluginName --plugin=FullClassName [--area=frontend|adminhtml]  ```

- To create observer

``` php bin/magento generate:code Module_Name --type=observer --name=ObserverName --event=event_name [--area=frontend|adminhtml]  ```

- To create cron

``` php bin/magento generate:code Module_Name --type=cron --name=CronName [--schedule="0 1 * * *"]  ```


- To create unit test cases

``` php bin/magento generate:code Module_Name --type=unit-test  ```


- To create view

``` php bin/magento generate:code Module_Name --type=create-view --name=webkul_index_index --area=adminhtml --block-class=Main --template=hello.phtml --layout-type=admin-2column-left ```

``` --block-class ```, ``` --template ```, ``` --layout-type ``` are optional.

- To create logger

``` php bin/magento generate:code Module_Name --type=logger [--name=loggerfile]  ```

- To create command

``` php bin/magento generate:code Module_Name --type=command --name=CommandClass --command='test:hello'  ```

- To override/rewrite a class (Block, Model, Controller)

``` php bin/magento generate:code Module_Name --type=rewrite --name=ClassName --rewrite='OverriddenClass' [--path=RelativeToModuleFolder]  ```

- To create email template

``` php bin/magento generate:code Module_Name --type=email --name="Email Label" [--id="module_email_test"] [--template="test"]  ```

- To create Ui Grid Listing

``` php bin/magento generate:code Module_Name --type=ui_component_listing --name="test_test" [--columns_name="test_column"] [--model_class_name="Model Class Name"][--table="Table Name"]   ```

- To create Ui Component Form

``` php bin/magento generate:code Module_Name --type=ui_component_form --name="test_test_form" [--provider_name="Data Provider Name"] [--model_class_name="Model Class Name"] [--fieldset_name="Field Set Name"] [--fieldset_label="Field Set Label"] [--submit_url="Form Submit Url"] [--form_field="Form Fields in Json Format"] ```

```  Ex : form_field = '[{"field_name": "test_input_field", "field_type": "input", "field_label": "Test Input Field", "is_required": "true"}, {"field_name": "test_image_field", "field_type": "imageUploader", "field_label": "Image Uploader", "is_required": "false", "image_upload_url": "test/test/upload"}]' ```

## Recent Versions

| Version | Released |
|---|---|
| 2.0.8 | 2024-05-13 |
| 2.0.7 | 2023-06-07 |
| 2.0.6 | 2023-03-29 |
| 2.0.5 | 2020-01-03 |
| 2.0.4 | 2019-12-20 |
| 2.0.3 | 2019-12-19 |
| 2.0.2 | 2019-12-19 |
| 2.0.1 | 2019-12-09 |
| 2.0.0 | 2019-12-09 |
| 1.0.0 | 2019-11-26 |

## Quality

Latest release (2.0.8) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | 1 | 1 |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 22 | 1 error, 21 warnings (ruleset: Magento2) — 7 auto-fixable with phpcbf |
| PHPMD | Warning | 145 | 145 rule violations (MissingImport:104, UnusedLocalVariable:28, ExcessiveMethodLength:4, UnusedFormalParameter:4, NPathComplexity:2) |
| Cpd | Warning | 1 | 1 duplicated chunk spanning 64 total lines (min-lines=5, min-tokens=70) |
| Composer validate | Info | 1 | valid; 1 advisory note (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 257 | 257 | – | – |
| 2.4.8 | – | 257 | 257 | – |
| 2.4.9 | – | – | 258 | 258 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["webkul/code-generator"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

webkul is a Magento 2 vendor on Packagento. See https://packagento.com/webkul.md for their full catalogue.

