ismaambrosi / generator-bundle
Generates Symfony2 documents, forms and CRUD
Installs: 89 570
Dependents: 1
Suggesters: 0
Security: 0
Stars: 26
Watchers: 4
Forks: 12
Open Issues: 4
Type:symfony-bundle
Requires
- php: >=5.3.3
- doctrine/mongodb-odm: ~1.0@dev
- sensio/generator-bundle: ~2.5|~3.0
Requires (Dev)
- phpspec/prophecy: ^1.4
- phpunit/phpunit: ^4.5
- symfony/dependency-injection: ~2.1
- twig/twig: >=1.4,<2.0-dev
This package is auto-updated.
Last update: 2024-10-12 06:10:04 UTC
README
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