ismaambrosi/generator-bundle

Generates Symfony2 documents, forms and CRUD

Installs: 89 686

Dependents: 1

Suggesters: 0

Security: 0

Stars: 26

Watchers: 4

Forks: 12

Open Issues: 4

Type:symfony-bundle

v2.5.0 2015-12-02 14:34 UTC

README

Build Status Total Downloads Latest Stable Version Latest Unstable Version SensioLabsInsight

This bundle extends the commands provided by SensioGeneratorBundle, adding a MongoDB document generator and CRUD generators for those MongoDB documents.

Installation

Add the bundle to your project.

Add the requirement to composer:

$ php composer.phar require ismaambrosi/generator-bundle

You will also need to install the DoctrineMongoDBBundle. The instructions on how to install it are available in the Symfony2 documentation.

Enable the bundle in your kernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    // ...
    if (in_array($this->getEnvironment(), array('dev', 'test'))) {
        // ...
        $bundles[] = new IsmaAmbrosi\Bundle\GeneratorBundle\IsmaAmbrosiGeneratorBundle();
    }
}

It is recommended to disable this bundle for the production environment.

Commands

This bundle contains three commands that will allow you to generate code for documents, forms and CRUD controllers. These commands can be executed either on interactive mode or manual mode. I would recommend you to use the interactive mode.

Generating ODM documents

The first command allows to generate the document classes.

Examples:

$ php app/console doctrine:mongodb:generate:document
$ php app/console doctrine:mongodb:generate:document \
--document=AcmeBlogBundle:Blog/Post \
--with-repository

Generating forms

With the second command we can generate the form type classes, used by the form component.

Example:

$ php app/console doctrine:mongodb:generate:form AcmeBlogBundle:Post

Generating the CRUD

The last command generates the CRUD controllers, with read-only actions to handle the documents that were generated previously. It also allows to include the write actions, for creating, updating and deleting documents.

Examples:

$ php app/console doctrine:mongodb:generate:crud
# Specifying the document and the routing prefix
$ php app/console doctrine:mongodb:generate:crud \
--document=AcmeBlogBundle:Post \
--route-prefix=post_admin
# Specifying the document, routing and write-actions
$ php app/console doctrine:mongodb:generate:crud \
--document=AcmeBlogBundle:Post \
--route-prefix=post_admin --with-write