{"id":27884061,"url":"https://github.com/ivanstan/symfony-extend-request","last_synced_at":"2025-06-25T19:02:58.751Z","repository":{"id":58631588,"uuid":"532817585","full_name":"ivanstan/symfony-extend-request","owner":"ivanstan","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-17T10:45:35.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T19:02:58.486Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivanstan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-05T08:50:12.000Z","updated_at":"2022-09-05T08:51:43.000Z","dependencies_parsed_at":"2022-09-11T22:51:02.106Z","dependency_job_id":null,"html_url":"https://github.com/ivanstan/symfony-extend-request","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ivanstan/symfony-extend-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanstan%2Fsymfony-extend-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanstan%2Fsymfony-extend-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanstan%2Fsymfony-extend-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanstan%2Fsymfony-extend-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivanstan","download_url":"https://codeload.github.com/ivanstan/symfony-extend-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanstan%2Fsymfony-extend-request/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261937019,"owners_count":23232843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-05-05T06:22:35.740Z","updated_at":"2025-06-25T19:02:58.728Z","avatar_url":"https://github.com/ivanstan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony extend request\r\n\r\nThis bundle allows users to annotate the controller method type with class that \r\nextends `Symfony\\Component\\HttpFoundation\\Request` and implement custom logic inside child class.\r\n\r\n## Example\r\n\r\n```php\r\nuse App\\Request\\ExtendedRequest;\r\n\r\nclass ProductsController extends AbstractController {\r\n\r\n    #[Route('product/search')]\r\n    public function search(SearchProductsRequest $request): JsonResponse\r\n    {\r\n        return new JsonResponse([\r\n            'name' =\u003e $request-\u003egetName(),\r\n        ]);\r\n    }\r\n    \r\n}\r\n```\r\n\r\n```php\r\nnamespace App\\Request;\r\n\r\nuse Symfony\\Component\\HttpFoundation\\Request;\r\n\r\nclass SearchProductsRequest extends Request\r\n{\r\n    public function getName(): string\r\n    {\r\n        return $this-\u003eget('name');\r\n    }\r\n}\r\n```\r\n\r\n## Installation\r\n```bash\r\ncomposer require ivanstan/symfony-extend-request\r\n```\r\nAdd to your project's `bundle.php`:\r\n```php\r\n\u003c?php\r\n\r\nreturn [\r\n    Ivanstan\\SymfonyExtendRequest\\SymfonyExtendRequestBundle::class =\u003e ['all' =\u003e true],\r\n];\r\n```\r\n\r\n## Requests as services\r\nClasses extending `Symfony\\Component\\HttpFoundation\\Request` can now be promoted to fully functional\r\nSymfony services, with all of its dependency injection features. Since request constructor is dedicated for\r\nquery params, headers, etc. `Required` attribute is encouraged to inject other services in extended request class, for example:\r\n\r\n```php\r\n\u003c?php\r\n\r\nnamespace App\\Request;\r\n\r\nuse Psr\\Log\\LoggerInterface;\r\nuse Symfony\\Component\\HttpFoundation\\Request;\r\nuse Symfony\\Contracts\\Service\\Attribute\\Required;\r\n\r\nclass ExtendedRequest extends Request\r\n{\r\n    protected LoggerInterface $logger;\r\n\r\n    #[Required]\r\n    public function setLogger(LoggerInterface $logger):void\r\n    {\r\n        $this-\u003elogger = $logger;\r\n    }\r\n}\r\n\r\n```\r\n\r\nThis will de-facto work if autowiring is enabled.\r\n\r\n## Testing\r\nRun: `composer test`\r\n\r\n## Next development steps\r\n- Support request validation in child classes.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanstan%2Fsymfony-extend-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanstan%2Fsymfony-extend-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanstan%2Fsymfony-extend-request/lists"}