{"id":36267980,"url":"https://github.com/sfmok/request-input-bundle","last_synced_at":"2026-01-11T08:42:28.205Z","repository":{"id":62908388,"uuid":"562421997","full_name":"sfmok/request-input-bundle","owner":"sfmok","description":"RequestInputBundle converts request data into DTO inputs objects with validation.","archived":false,"fork":false,"pushed_at":"2024-10-03T11:22:47.000Z","size":76,"stargazers_count":35,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-10T03:26:55.201Z","etag":null,"topics":["dto","dto-input","input","input-validation","inputs","request-dto"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sfmok.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-11-06T10:05:44.000Z","updated_at":"2024-12-22T00:47:55.000Z","dependencies_parsed_at":"2024-03-21T22:47:24.101Z","dependency_job_id":null,"html_url":"https://github.com/sfmok/request-input-bundle","commit_stats":{"total_commits":63,"total_committers":2,"mean_commits":31.5,"dds":0.07936507936507942,"last_synced_commit":"f06c5d0c438bbb704f078f1fe3271a3b48e87654"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/sfmok/request-input-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfmok%2Frequest-input-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfmok%2Frequest-input-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfmok%2Frequest-input-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfmok%2Frequest-input-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sfmok","download_url":"https://codeload.github.com/sfmok/request-input-bundle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfmok%2Frequest-input-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28298861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T08:21:30.231Z","status":"ssl_error","status_checked_at":"2026-01-11T08:21:26.882Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dto","dto-input","input","input-validation","inputs","request-dto"],"created_at":"2026-01-11T08:42:27.820Z","updated_at":"2026-01-11T08:42:28.197Z","avatar_url":"https://github.com/sfmok.png","language":"PHP","readme":"## RequestInputBundle\n[![CI](https://github.com/sfmok/request-input/actions/workflows/ci.yml/badge.svg)](https://github.com/sfmok/request-input/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/github/sfmok/request-input-bundle/branch/main/graph/badge.svg?token=9EDGRUPYCB)](https://codecov.io/github/sfmok/request-input-bundle)\n[![Latest Stable Version](http://poser.pugx.org/sfmok/request-input-bundle/v/stable)](https://packagist.org/packages/sfmok/request-input-bundle)\n[![License](http://poser.pugx.org/sfmok/request-input-bundle/license)](https://packagist.org/packages/sfmok/request-input-bundle)\n\n**RequestInputBundle** converts request data into DTO inputs objects with validation.\n\n- Request data supported: `json`, `xml` and `form` based on `Content-Type` header.\n- Resolve inputs arguments for controllers actions.\n- Create DTO inputs outside controllers\n- Validate DTO inputs objects.\n- Global YAML configuration.\n- Custom Configuration via Input Attribute per controller action.\n\n### Installation\nRequire the bundle with composer:\n```bash\ncomposer require sfmok/request-input-bundle\n```\n\n### How to use\n\n- Create DTO input and implements `Sfmok\\RequestInput\\InputInterface`\n```php\nuse Sfmok\\RequestInput\\InputInterface;\n\nclass PostInput implements InputInterface\n{\n    #[Assert\\NotBlank]\n    private string $title;\n\n    #[Assert\\NotBlank]\n    private string $content;\n\n    #[Assert\\NotBlank]\n    private array $tags;\n\n    #[SerializedName('author')]\n    #[Assert\\NotBlank]\n    private string $name;\n    \n    # getters and setters or make properties public\n}\n```\n- Use DTO input in your controller action as an argument:\n```php\nclass PostController\n{\n    # Example with global config\n    #[Route(path: '/posts', name: 'create')]\n    public function create(PostInput $input): Response\n    {\n        dd($input);\n    }\n    \n    # Example with specific config\n    #[Route(path: '/posts', name: 'create')]\n    #[Input(format: 'json', groups: ['create'], context: ['groups' =\u003e ['create']])]\n    public function create(PostInput $input): Response\n    {\n        dd($input);\n    }\n}\n```\n\n### Validations\n- Response header\n```\nContent-Type: application/json; charset=utf-8\n```\n- Response body\n```json\n{\n  \"type\": \"https://symfony.com/errors/validation\",\n  \"title\": \"Validation Failed\",\n  \"detail\": \"title: This value should not be blank.\",\n  \"violations\": [\n    {\n      \"propertyPath\": \"title\",\n      \"title\": \"This value should not be blank.\",\n      \"parameters\": {\n        \"{{ value }}\": \"\\\"\\\"\"\n      },\n      \"type\": \"urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3\"\n    }\n  ]\n}\n```\n\n### Deserialization\n\nWhether the request data contains invalid syntax or invalid attributes types a clear 400 json response will return:\n\n- Data Error\n\n```json\n{\n  \"title\": 12\n}\n```\n```json\n{\n  \"title\": \"Deserialization Failed\",\n  \"detail\": \"Data error\",\n  \"violations\": [\n    {\n      \"propertyPath\": \"title\",\n      \"message\": \"This value should be of type string\",\n      \"currentType\": \"int\"\n    }\n  ]\n}\n```\n- Syntax error:\n```json\n{\n  \"title\": \"foo\",\n}\n```\n```json\n{\n  \"title\": \"Deserialization Failed\",\n  \"detail\": \"Syntax error\",\n  \"violations\": []\n}\n```\n\n### Configuration\n\n```yaml\n# config/packages/request_input.yaml\nrequest_input:\n  enabled: true # default value true\n  formats: ['json'] # default value ['json', 'xml', 'form']\n  skip_validation: true # default value false\n```\n\nYou can also override the format using attribute input and specify the format explicitly.\n\n### Create DTO input outside controller\n\nYou just need to inject `InputFactoryInterface` e.g:\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Manager;\n\nuse App\\Dto\\PostInput;\nuse Sfmok\\RequestInput\\InputInterface;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Sfmok\\RequestInput\\Factory\\InputFactoryInterface;\n\nclass PostManager\n{\n    public function __construct(private InputFactoryInterface $inputFactory)\n    {\n    }\n\n    public function getInput(Request $request): InputInterface\n    {\n        return $this-\u003einputFactory-\u003ecreateFromRequest($request, PostInput::class);\n    }\n}\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfmok%2Frequest-input-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsfmok%2Frequest-input-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfmok%2Frequest-input-bundle/lists"}