Norway



Vladimir Sadicov  - 3df61b66 6986 4eb2 ac0d f2ecfcaaf8d6 - New and improved generators for MakerBundle (Symfony Blog)

Symfony Maker Bundle is the fastest way to generate the most common code
you’ll need in a : commands, controllers, form classes, event
subscribers, etc. This bundle was introduced in time for the Symfony 4 release
and it’s an alternative to SensioGeneratorBundle in modern Symfony apps.

During the past months we’ve been busy improving it and its latest 1.2.0 version
includes two new interesting features.

This new generator is similar to the well-known doctrine:generate:crud
command from SensioGeneratorBundle and it generates a basic CRUD interface
for the given Doctrine entity:

 1
 2
 3
 4
 5
 6
 7
 8
 9

11
$ bin/console make:crud BlogPost

  created: src/Controller/BlogPostController.php
  created: src/Form/BlogPostType.php
  created: templates/_post/_delete_form.html.twig
  created: templates/blog_post/_form.html.twig
  created: templates/blog_post/index.html.twig
  created: templates/blog_post/show.html.twig
  created: templates/blog_post/new.html.twig
  created: templates/blog_post/edit.html.twig

  Success!

Although this generator is not (and it will never be) a full-featured admin
generator, it can be useful to quickly bootstrap some feature in your projects.

The existing make:form generator created the skeleton of a
Symfony Form class so you could quickly add the needed form fields. In the
new version, this generator is smarter and it can optionally generate a complete
form class based on a Doctrine entity, adding a form field for every property of
the entity:

$ bin/console make:form

  The name of the form class (e.g. GentleElephantType):
  > BlogPostType

  Enter the class or entity name that the new form will be bound to (empty for none):
  > BlogPost

  created: src/Form/BlogPostType.php

  Success!



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here