dakataa / crud
Symfony CRUD
v1.0.2
2025-02-18 15:43 UTC
Requires
- php: >=8.1
- doctrine/orm: >=2.10.0
- phpoffice/phpspreadsheet: ^4.0.0
- symfony/expression-language: ^7.0
- symfony/form: ^7.0
- symfony/framework-bundle: ^7.0
- symfony/http-kernel: ^7.0
- symfony/security-bundle: ^7.0
- symfony/serializer: ^7.0
- symfony/validator: ^7.0
Requires (Dev)
- symfony/maker-bundle: ^1.61
README
Create fast and easy CRUD Dashboard. This package itself works as a REST API and can be used with ReactJS Package dakataa/crud-react, or you can enable Twig version by adding additional package dakataa/crud-twig.
How to Install
-
Setup Symfony Project.
symfony new --webapp crud
-
Create Entity And Form Type
php bin/console make:entity Product php bin/console make:form ProductType Product ... php bin/console make:migration php bin/console doctrine:migrations:migrate
-
Add package to composer
composer require dakataa/crud
add routes without recipe in config/routes/annotation.yaml:
dakataa_crud: resource: '@DakataaCrudBundle/src/Controller' type: attribute prefix: /_crud
-
Allow controllers to inject services. Add this code to your services.yaml controllers are imported separately to make sure services can be injected
App\Controller\: resource: '../src/Controller' tags: [ 'controller.service_arguments' ]
-
Create first controller. Standard way:
namespace App\Controller; use App\Entity\Product; use App\Form\ProductType; use Dakataa\Crud\Attribute\Entity; use Dakataa\Crud\Attribute\EntityType; use Dakataa\Crud\Controller\AbstractCrudController; use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; #[Route('/product')] #[Entity(Product::class)] #[EntityType(ProductType::class)] class ProductController extends AbstractCrudController { }
if you want to customize initial query. This method is called before query execution.
public function buildCustomQuery(Request $request, QueryBuilder $query): AbstractCrudController { $query ->andWhere('a.enabled = true'); return $this; }
with Make Command
php symfony crud:make:entity Product ProductType ProductController