philipphermes/symfony-layered-architecture
最新稳定版本:1.0.1
Composer 安装命令:
composer require philipphermes/symfony-layered-architecture
包简介
Provides a Twig compiler pass and routing loaders that enable support for a layered architecture.
README 文档
README
Provides a Twig compiler pass and routing loaders that enable support for a layered architecture.
Table of Contents
Installation
composer require philipphermes/symfony-layered-architecture
Register Twig Compiler Pass
<?php namespace App; use PhilippHermes\Symfony\LayeredArchitecture\Shared\Twig\TwigPathCompilerPass; use PhilippHermes\Symfony\LayeredArchitecture\Shared\Twig\TwigPathRegistrator\Plugin\BackendTwigRegistratorPlugin; use PhilippHermes\Symfony\LayeredArchitecture\Shared\Twig\TwigPathRegistrator\Plugin\FrontendTwigRegistratorPlugin; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseKernel; class Kernel extends BaseKernel { use MicroKernelTrait; /** * @inheritDoc */ protected function build(ContainerBuilder $container): void { $twigPathCompilerPass = new TwigPathCompilerPass([ //TwigRegistratorPlugins new BackendTwigRegistratorPlugin(), new FrontendTwigRegistratorPlugin(), //you can add your own ones e.g. when you have an additional layer like for merchants ]); $container->addCompilerPass($twigPathCompilerPass); } }
Update services.yaml
parameters: services: _defaults: autowire: true autoconfigure: true App\: resource: '../src/' exclude: - '../src/DependencyInjection/' - '../src/Kernel.php' - '../src/Backend/.+/Persistence/Entity/' - '../src/Generated/' PhilippHermes\Symfony\LayeredArchitecture\Shared\Routing\ControllerLoader: arguments: $classLoader: '@routing.loader.attribute' $projectDir: '%kernel.project_dir%' tags: - { name: routing.loader }
Update routes.yaml
modular_controllers: resource: . type: modular
Update doctrine.yaml
doctrine: ... orm: validate_xml_mapping: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware identity_generation_preferences: Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity auto_mapping: true mappings: App: type: attribute is_bundle: false dir: '%kernel.project_dir%/src/Backend' prefix: 'App\Backend' alias: Backend ...
Update doctrine_migrations.yaml
doctrine_migrations: migrations_paths: 'DoctrineMigrations': '%kernel.project_dir%/src/Generated/Migrations' enable_profiler: false
install deptrac:
composer require --dev deptrac/deptrac
Add deptrac.yaml to your project root:
deptrac: paths: - ./src exclude_files: - '#.*test.*#i' layers: - name: Backend_Business collectors: - type: directory value: src/Backend/.+/Business/.* - name: Backend_Persistence collectors: - type: directory value: src/Backend/.+/Persistence/.* - name: Backend_Communication collectors: - type: directory value: src/Backend/.+/Communication/.* - name: Backend_Presentation collectors: - type: directory value: src/Backend/.+/Presentation/.* - name: Frontend_Controller collectors: - type: directory value: src/Frontend/.+/Controller/.* - name: Frontend_Theme collectors: - type: directory value: src/Frontend/.+/Theme/.* - name: Client collectors: - type: directory value: src/Client/.+/* - name: Service collectors: - type: directory value: src/Service/.+/* - name: Shared collectors: - type: directory value: src/Shared/.+/* - name: Generated collectors: - type: directory value: src/Generated/* - name: Doctrine collectors: - type: classLike value: ^Doctrine\\.* - name: Vendor collectors: - type: classLike value: ^(Symfony|Psr|Monolog|Ramsey|League)\\.* #need to find a better solution ruleset: Backend_Business: - Backend_Business - Backend_Persistence - Service - Shared - Generated - Vendor Backend_Persistence: - Backend_Persistence - Service - Shared - Generated - Doctrine - Vendor Backend_Communication: - Backend_Communication - Backend_Business - Service - Shared - Generated - Vendor Backend_Presentation: - Backend_Presentation Frontend_Controller: - Frontend_Controller - Client - Service - Shared - Generated - Vendor Frontend_Theme: - Frontend_Theme Client: - Backend_Business - Client - Service - Shared - Generated - Vendor Service: - Service - Shared - Generated - Vendor Shared: - Shared - Generated - Vendor Generated: - Generated - Vendor - Doctrine # need this because of migrations
Code Quality
Deptrac
vendor/bin/deptrac
Phpstan
vendor/bin/phpstan analyse --memory-limit=1G
Test
Phpunit
vendor/bin/phpunit
# With coverage
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html coverage-report
统计信息
- 总下载量: 101
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-18