Skip to content

jeandanyel/crud-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crud-bundle

The CRUD Bundle provides a quick and easy way to generate Create, Read, Update, and Delete actions for any given entity in your Symfony projects. This bundle is designed to simplify entity management by automating CRUD operations while remaining flexible and easy to customize.

Additionally, it integrates list generation through the jeandanyel/list-bundle, offering a customizable solution for displaying and managing your data.

This bundle is actively under development, with upcoming features such as role management and event handling. Contributions to the project are always welcome 🥳.

Usage

To use this bundle, simply create an Entity, its corresponding Repository, a FormType, a ListType and a Controller that extends the abstract class AbstractCrudController.

Use the CrudController attribute to specify the Entity, FormType, and ListType classes as parameters.

namespace App\Controller;

use App\Entity\Article;
use App\Form\ArticleType;
use App\List\ArticleListType;
use Jeandanyel\CrudBundle\Attribute\CrudController;
use Jeandanyel\CrudBundle\Controller\AbstractCrudController;

#[CrudController(entityClass: Article::class, formTypeClass: ArticleType::class, listTypeClass: ArticleListType::class)]
class ArticleController extends AbstractCrudController
{
}

This configuration will automatically set up CRUD actions for the Article entity.

Routes

The routes for the CRUD actions are automatically generated by the bundle using the RouteLoader. This means you don't have to manually configure the routes for each entity.

Templates

The bundle provides default templates used for the list, create, and update actions.

If these templates do not meet your needs, you can create your own custom templates by following the naming convention based on your entity and the desired action. Your custom template will take priority over the default ones.

The format to follow for your custom templates is templates/{entity}/{action}.html.twig.

For example, if you want to create a custom template for the Article entity and the update action, the Twig file should be created at templates/article/update.html.twig.

CRUD actions list

Method Route name Route Template
AbstractCrudController::list crud_{entity}_list /{entity}/list @JeandanyelCrud/crud/list.html.twig
AbstractCrudController::create crud_{entity}_create /{entity}/create @JeandanyelCrud/crud/create.html.twig
AbstractCrudController::update crud_{entity}_update /{entity}/update/{id} @JeandanyelCrud/crud/update.html.twig
AbstractCrudController::delete crud_{entity}_delete /{entity}/delete/{id} -

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published