dakataa/crud
最新稳定版本:v1.1.0
Composer 安装命令:
composer require dakataa/crud
包简介
Symfony CRUD
README 文档
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
How to extend templates
Map URL parameter to entity column
How to ...
统计信息
- 总下载量: 52
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-09