2017 © Pedro Peláez
 

symfony-bundle generator-bundle

Code generation tool for Symfony3.

image

remg/generator-bundle

Code generation tool for Symfony3.

  • Wednesday, September 20, 2017
  • by Remg
  • Repository
  • 1 Watchers
  • 20 Stars
  • 4,390 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 5 Open issues
  • 1 Versions
  • 25 % Grown

The README.md

RemgGeneratorBundle

Build Status Test Coverage SensioLabsInsight, (*1)

Introduction

This bundle provides commands to intuitively generate code inside Symfony-based projects., (*2)

Overview

Example, (*3)

Features

1. Entity generation

Fields

Associations

  • Handles all Doctrine2 association types (OneToOne, OneToMany, ManyToOne, ManyToMany).
  • Handles unidirectional and bidirectional associations.
  • Auto-detect association mappings when generating an Entity already targetted by other entities.

Configuration formats

2. Entity re-generation

The bundle provides a command that will start an entity generation from the mappping informations of an existing entity. It is then possible to edit or add fields and associations before the entity is regenerated from scratch., (*4)

This same command can be used to regenerate an entity in a different mapping configuration format., (*5)

Installation

Step 1: Download the bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*6)

$ composer require --dev remg/generator-bundle dev-master

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*7)

Step 2: Enable the bundle

Then, enable the bundle by adding new Remg\GeneratorBundle\RemgGeneratorBundle() to the list of registered bundles for the dev environment in the app/AppKernel.php file of your project:, (*8)

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        // ...
        if (in_array($this->getEnvironment(), ['dev', 'test'])) {
            $bundles[] = new Remg\GeneratorBundle\RemgGeneratorBundle();
            // ...
        }
    }
    // ...
}

Step 3: Configure the bundle

The bundle comes with a default configuration, which is listed below. You can define these options in your configuration if you need to change them:, (*9)

remg_generator:
    entity:
        # available configuration formats are: 'annotation', 'yaml', 'xml' and 'php'.
        configuration_format: annotation

Since this bundle is only useful in command line interface, you can override the bundle configuration in your development configuration in app/config/config_dev.yml., (*10)

Usage

You can now generate new Doctrine2 entities using the command below:, (*11)

$ php bin/console remg:generate:entity

You can also regenerate Doctrine2 entities from scratch using the command below:, (*12)

$ php bin/console remg:regenerate:entity

NOTE: Since this bundle can only generate code, and not manipulate existing code, this command will regenerate the entity from scratch without implementing any custom code that could live in the existing entity., (*13)

No code can be lost. Each file generation checks if the target file already exists, and creates a timestamped backup of the file before generation., (*14)

Under development

  • Repository generation.
  • Entity edition.
  • CRUD generation (handling embed form collections).

License

This bundle is under the MIT license. See the complete license in the bundle., (*15)

The Versions