twc/maker-bundle
Composer 安装命令:
composer require twc/maker-bundle
包简介
Wrap maker bundle to introduce context option to change destination template
README 文档
README
When your symfony architecture is different like (ddd, cqrs, adr, custom architecture) you lost the powerfull of makerBundle, because directory structure is not at the same place. TwcMakerBundle try to revolve that, to wrap maker command and introduce "context" option.
Installation
composer require twc/maker-bundle --dev
Basic Usage
Generic configuration
#config/packages/dev/twc_maker.yaml twc_maker: componentName: - { context: 'contextName', target: 'Your\SpecificNamespace' } - { context: 'contextName1', target: 'Your\SpecificNamespace' } - ...
Specific configuration
Component entity
for entity component you must use target_entity and target_repository instead target
#config/packages/dev/twc_maker.yaml twc_maker: entity: - { context: 'contextName', target_entity: 'Your\SpecificEntityNamespace', target_repository: 'Your\SpecificRepositoryNamespace' }
Component controller
for controller you can specific dir to change generation folder (default contextName)
#config/packages/dev/twc_maker.yaml twc_maker: controller: - { context: 'contextName', target: 'Your\SpecificNamespace', dir: 'my/custom/directory/template' }
Console
TwcMakerBundle wrap maker command and add new option --context (shortcut -c)
Sample with CQRS concept
#config/packages/dev/twc_maker.yaml twc_maker: message: - { context: 'post.command', target: 'App\Post\Application\Command' } - { context: 'post.query', target: 'App\Post\Application\Query' }
in your console
php bin/console make:twc:message NewPost --context=post.command php bin/console make:twc:message AllPostsArchivedQuery --context=post.query
#shortcut version
php bin/console make:twc:message NewPost -c post.command
php bin/console make:twc:message AllPostsArchivedQuery -c post.query
results
created: src/Post/Application/Command/NewPost.php created: src/Post/Application/Command/NewPostHandler.php created: src/Post/Application/Query/AllPostArchivedQuery.php created: src/Post/Application/Query/AllPostArchivedQueryHandler.php
Sample with DDD concept
#config/packages/dev/twc_maker.yaml twc_maker: entity: - { context: 'membership', target_entity: 'App\MemberShip\Domain\Entity', target_repository: 'App\MemberShip\Infrastructure\Doctrine\Repository' } controller: - { context: 'membership', target: 'App\MemberShip\Presenter\Controller' } form: - { context: 'membership', target: 'App\MemberShip\Presenter\Form' }
in your console
php bin/console make:twc:entity UserMembership -c membership
result
created: src/Membership/Domain/Entity/UserMemberShip.php created: src/Membership/Infrastructure/Doctrine/Repository/UserMemberShipRepository.php
Troubleshooting
Specific directory not created
If your specific directory not created, clean cache and retry.
php bin/console c:c
Could not determine where to locate the new class
If you have error message like
Could not determine where to locate the new class "xxx" maybe try with a full namespace like
Check your composer.json with PSR-4 config, maybe you need to add your namespace, or try with App\
Support
Actually TwcMakerBundle wrap 9 components
| components |
|---|
| controller |
| validator |
| form |
| message |
| messenger-middleware |
| voter |
| command |
| fixtures |
| entity |
twc/maker-bundle 适用场景与选型建议
twc/maker-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.99k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2020 年 04 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 twc/maker-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 twc/maker-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 17.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-21