intellect-web-development/symfony-entry-contract-bundle
Composer 安装命令:
composer require intellect-web-development/symfony-entry-contract-bundle
包简介
SymfonyEntryContract Symfony bundle for pretty contracts
README 文档
README
HTTP Entry:
InputContract:
<?php declare(strict_types=1); namespace App\Entry\Http\Root; use IWD\SymfonyEntryContract\Interfaces\InputContractInterface; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotNull; class InputContract implements InputContractInterface { #[NotNull] #[Length(min: 3, max: 255)] public string $name; }
Http Action/Controller:
<?php declare(strict_types=1); namespace App\Entry\Http\Root; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; class Action { #[Route(path: '', methods: ['GET'])] public function action( InputContract $inputContract ): Response { return new Response($inputContract->name); } }
CLI Entry:
InputContract:
<?php declare(strict_types=1); namespace App\Entry\Console\Demo; use IWD\SymfonyEntryContract\Interfaces\InputContractInterface; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotNull; class InputContract implements InputContractInterface { /** User email */ #[NotNull] #[NotBlank] public string $email = 'user@dev.com'; /** User name */ #[NotNull] #[NotBlank] #[Length(min: 1)] public string $name = 'Foo'; /** Root user password */ #[NotNull] #[NotBlank] #[Length(min: 4)] public string $password = 'bar'; }
CliCommand:
<?php declare(strict_types=1); namespace App\Entry\Console\Demo; use IWD\SymfonyEntryContract\Attribute\CliContract; use IWD\SymfonyEntryContract\Console\CliCommand; use IWD\SymfonyEntryContract\Interfaces\InputContractInterface; use IWD\SymfonyEntryContract\Service\CliContractResolver; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand( name: 'app:demo', description: 'Demo CLI', )] #[CliContract(class: InputContract::class)] class DemoCommand extends CliCommand { public function __construct( CliContractResolver $cliContractResolver, ) { parent::__construct($cliContractResolver); } /** * @param InputContract $inputContract */ protected function handle(SymfonyStyle $io, InputContractInterface $inputContract): int { $io->success( sprintf( '%, %, %', $inputContract->name, $inputContract->email, $inputContract->password ) ); return self::SUCCESS; } }
Command help:
php bin/console app:demo -h
Result:
Description:
Demo CLI
Usage:
app:demo [options]
Options:
--email=EMAIL User email [default: "user@dev.com"]
--name=NAME User name [default: "Foo"]
--password=PASSWORD Root user password [default: "bar"]
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The Environment name. [default: "dev"]
--no-debug Switch off debug mode.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
intellect-web-development/symfony-entry-contract-bundle 适用场景与选型建议
intellect-web-development/symfony-entry-contract-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.6k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 09 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 intellect-web-development/symfony-entry-contract-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 intellect-web-development/symfony-entry-contract-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.6k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-03