{"id":22093193,"url":"https://github.com/iadvize/php-swaggerize-fastroute-library","last_synced_at":"2025-10-05T22:32:25.703Z","repository":{"id":56987977,"uuid":"44521694","full_name":"iadvize/php-swaggerize-fastroute-library","owner":"iadvize","description":"A library to automatically create FastRoute (Lumen ready) routes based on swagger JSON documentation","archived":false,"fork":false,"pushed_at":"2024-08-13T09:13:20.000Z","size":31,"stargazers_count":19,"open_issues_count":2,"forks_count":1,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-08-04T05:16:16.373Z","etag":null,"topics":["fastroute","laravel","lumen","swagger"],"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/iadvize.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-19T08:41:01.000Z","updated_at":"2024-08-13T09:13:24.000Z","dependencies_parsed_at":"2024-12-01T03:23:24.506Z","dependency_job_id":null,"html_url":"https://github.com/iadvize/php-swaggerize-fastroute-library","commit_stats":{"total_commits":29,"total_committers":3,"mean_commits":9.666666666666666,"dds":"0.31034482758620685","last_synced_commit":"3b7015156eeb587e2ef1561a529901bd6a28745d"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/iadvize/php-swaggerize-fastroute-library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iadvize%2Fphp-swaggerize-fastroute-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iadvize%2Fphp-swaggerize-fastroute-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iadvize%2Fphp-swaggerize-fastroute-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iadvize%2Fphp-swaggerize-fastroute-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iadvize","download_url":"https://codeload.github.com/iadvize/php-swaggerize-fastroute-library/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iadvize%2Fphp-swaggerize-fastroute-library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278531928,"owners_count":26002338,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["fastroute","laravel","lumen","swagger"],"created_at":"2024-12-01T03:13:15.844Z","updated_at":"2025-10-05T22:32:25.658Z","avatar_url":"https://github.com/iadvize.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":" php-swaggerize-fastroute-library [![CircleCI](https://circleci.com/gh/iadvize/php-swaggerize-fastroute-library.svg?style=svg)](https://circleci.com/gh/iadvize/php-swaggerize-fastroute-library) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/iadvize/php-swaggerize-fastroute-library/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/iadvize/php-swaggerize-fastroute-library/?branch=master)\n=================================\n\n\u003e **⚠️ WARNING**: This repository is deprecated and no longer maintained since 2015. See removal guide [here](#removal-guide).\n\nA library to automatically create FastRoute routes based on swagger JSON documentation\n\n## Removal guide\n\nThis library is deprecated and no longer maintained since 2015. Here is a guide to remove it from your project:\n\n- check that your app uses this library `iadvize/php-swaggerize-fastroute-library` (search for `Iadvize\\SwaggerizeFastRoute` package import in php code). If it does not, you can safely remove it from your `composer.json` and skip the next steps.\n- if your CI/CD or dockerfile uses the `swaggerize swagger:scan` command, you should:\n  - run it manually once (use your full existing command, eg: `./vendor/bin/swaggerize swagger:scan storage/docs/definition.json \"path/to/controllers\" --routeFile somewhere/routeFile.php`)\n  - remove the `swaggerize swagger:scan` command from your CI/CD or dockerfile\n- convert the generated route file to a standard FastRoute setup (see [FastRoute documentation](https://github.com/nikic/FastRoute?tab=readme-ov-file#usage)), usually the same file as the one using the `Iadvize\\SwaggerizeFastRoute` package.\n- remove the `Iadvize\\SwaggerizeFastRoute` package import from your php code and all usage.\n- remove the `iadvize/php-swaggerize-fastroute-library` from your `composer.json` (eg: `composer remove iadvize/php-swaggerize-fastroute-library`)\n- delete the routeFile.php file (not needed anymore)\n\n## Examples\n\n### Generate route File (FastRoute compatible)\n\n```\nvendor/bin/swaggerize swagger:scan path/to/swagger/json controllers\\namespace [--routeFile=route/file/path]\n```\n\n## Install\n\nTo install with composer:\n```\ncomposer require iadvize/php-swaggerize-fastroute-library\n```\n\n## Documentation\n\n### Generate route File (FastRoute compatible)\n\n```\nvendor/bin/swaggerize swagger:scan path/to/swagger/json controllers\\namespace [--routeFile=route/file/path]\n```\n\n### Dispatch generated file or simply use cache\n\nYou can then use FastRoute cached dispatcher to use generated file or directly use a cache dispatcher (file will be generated at first call).\n\n```PHP\n\u003c?php\n\nrequire '/path/to/vendor/autoload.php';\n\n$lumenOperationParser = new \\Iadvize\\SwaggerizeFastRoute\\OperationParser\\LumenControllerOperationParser('Controllers\\\\Namespace\\\\');\n\n$dispatcher = FastRoute\\simpleDispatcher(function(FastRoute\\RouteCollector $r, ['cacheFile' =\u003e 'route/file/path']) {\n    \\Iadvize\\SwaggerizeFastRoute\\addRoutes(\n        'path/to/swagger/json',\n         $r,\n         $lumenOperationParser,\n         ['routeFile' =\u003e 'path/to/generated/route/file', 'cacheEnabled' =\u003e false]\n     );\n});\n\n// Fetch method and URI from somewhere\n// ... see FastRoute Dispatcher\n```\n\nAlternatively to generate routes, you can simply cache first parse by setting `'cacheEnabled' =\u003e true` in addRoute function.\n\n### Apply this to Lumen application\n\nTo use this swagger routes in a Lumen Application (which use FastRoute as route library), you need to extends `Laravel\\Lumen\\Application` and override `createDispatcher` method.\n\n```PHP\n\n\u003c?php\n\nnamespace My\\Application;\n\nuse Laravel\\Lumen\\Application as LumenApplication;\n\n/**\n * Class Application\n *\n * @package My\\Application\n */\nclass Application extends LumenApplication\n{\n    /**\n     * {@inheritdoc}\n     */\n    protected function createDispatcher()\n    {\n        return $this-\u003edispatcher ?: \\FastRoute\\simpleDispatcher(function ($r) {\n            foreach ($this-\u003eroutes as $route) {\n                $r-\u003eaddRoute($route['method'], $route['uri'], $route['action']);\n            }\n\n            $operationParser = new \\Iadvize\\SwaggerizeFastRoute\\OperationParser\\LumenControllerOperationParser('My\\Application\\Http\\Controllers');\n\n            \\Iadvize\\SwaggerizeFastRoute\\addRoutes(storage_path('docs/definition.json'), $r, $operationParser, ['routeFile' =\u003e 'route/file/path']);\n        });\n    }\n}\n```\n\n### How handler is formed\n\nHandlers are formed from route defined in swagger as [Lumen](http://lumen.laravel.com/docs/routing#named-routes) define it for controller class : `Controller@method`\n\n#### Controller class generation\n\nController class is determined from path route with first character uppercased and with Controller at the end of file name\n\nThis swagger JSON :\n\n```JSON\n{\n// ...\n  \"paths\": {\n    \"/pets\": {\n      \"get\": {\n        // ...\n      }\n      \"put\": {\n        // ...\n      }\n    }\n    \"/store\": {\n      \"post\": {\n        // ...\n      }\n    }\n  }\n// ...\n}\n```\n\nwill generates respectively this handlers:\n\n* `PetsController@get`\n* `PetsController@update`\n* `StoreController@create`\n\n#### Method generation\n\nController method is mapped from HTTP method :\n* `GET`     =\u003e `get`,\n* `POST`    =\u003e `create`,\n* `PUT`     =\u003e `update`,\n* `HEAD`    =\u003e `head`,\n* `OPTIONS` =\u003e `options`,\n* `PATCH`   =\u003e `patch`,\n* `DELETE`  =\u003e `delete`,\n\n## Contribute\n\nLook at contribution guidelines here : [CONTRIBUTING.md](CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiadvize%2Fphp-swaggerize-fastroute-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiadvize%2Fphp-swaggerize-fastroute-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiadvize%2Fphp-swaggerize-fastroute-library/lists"}