Created
December 6, 2025 11:10
-
-
Save akky/442a318a78c6bd6fdbe09f3b2246c8ea to your computer and use it in GitHub Desktop.
sample DTO for Symfony command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Dto; | |
| use App\Enum\City; | |
| use Symfony\Component\Console\Attribute\Argument; | |
| use Symfony\Component\Console\Attribute\Option; | |
| use Symfony\Component\Validator\Constraints as Assert; | |
| class WeatherInput | |
| { | |
| #[Argument(description: '天気を知りたい都市名')] | |
| #[Assert\NotBlank(message: '都市名を入力してください。')] | |
| #[Assert\Choice( | |
| callback: [City::class, 'getNames'], | |
| message: '指定された都市名は無効です。利用可能な都市名: {{ choices }}' | |
| )] | |
| public string $city; | |
| #[Option( | |
| description: '温度を華氏で表示する', | |
| shortcut: 'f' | |
| )] | |
| public bool $fahrenheit = false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment