{"id":37235953,"url":"https://github.com/marcguyer/version-middleware","last_synced_at":"2026-01-16T04:51:46.621Z","repository":{"id":62523786,"uuid":"146336413","full_name":"marcguyer/version-middleware","owner":"marcguyer","description":"Provides version detection, making versioned resource routing possible in PSR-7 applications.","archived":false,"fork":false,"pushed_at":"2023-06-16T21:30:17.000Z","size":52,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-29T16:44:30.124Z","etag":null,"topics":["middleware","php","psr-7"],"latest_commit_sha":null,"homepage":null,"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/marcguyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-27T18:16:25.000Z","updated_at":"2024-01-21T10:58:07.000Z","dependencies_parsed_at":"2022-11-02T15:31:54.826Z","dependency_job_id":null,"html_url":"https://github.com/marcguyer/version-middleware","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marcguyer/version-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcguyer%2Fversion-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcguyer%2Fversion-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcguyer%2Fversion-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcguyer%2Fversion-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcguyer","download_url":"https://codeload.github.com/marcguyer/version-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcguyer%2Fversion-middleware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["middleware","php","psr-7"],"created_at":"2026-01-15T04:05:21.304Z","updated_at":"2026-01-15T04:05:21.900Z","avatar_url":"https://github.com/marcguyer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Versioning for PSR-7 apps\n\n[![Build Status](https://secure.travis-ci.org/marcguyer/version-middleware.svg?branch=master)](https://secure.travis-ci.org/marcguyer/version-middleware)\n[![Coverage Status](https://coveralls.io/repos/github/marcguyer/version-middleware/badge.svg?branch=master)](https://coveralls.io/github/marcguyer/version-middleware?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/marcguyer/version-middleware/v/stable)](https://packagist.org/packages/marcguyer/version-middleware)\n[![Total Downloads](https://poser.pugx.org/marcguyer/version-middleware/downloads)](https://packagist.org/packages/marcguyer/version-middleware)\n\nProvides version detection, making versioned resource routing possible in PSR-7 applications.\n\n## Installation\n\nInstall this library using composer:\n\n```bash\n$ composer require marcguyer/version-middleware\n```\n\nComposer will ask if you'd like to inject the ConfigProvider if you're using `zendframework/zend-component-installer`. Answer yes or config it by hand.\n\n## Usage\n\n### Config\n\nSee the [ConfigProvider](src/ConfigProvider.php) for config defaults. You may override using the `versioning` key. For example, the default version is `1`. You might release a new version and set the default version to `2`. Any clients not specifying a version via path or header will then be hitting version 2 resources.\n\n### Add to pipeline\n\nWire this middleware into your pipeline before routing. An example using a Zend Expressive pipeline:\n\n```php\n...\n$app-\u003epipe(ServerUrlMiddleware::class);\n...\n$app-\u003epipe(Psr7Versioning\\VersionMiddleware::class);\n...\n$app-\u003epipe(RouteMiddleware::class);\n...\n```\n\n### Routing\n\nNow, you can route based on the rewritten URI path. For example, in Expressive:\n\n```php\n$app-\u003eget('/api/v1/ping', Api\\Handler\\PingHandler::class, 'api.ping');\n$app-\u003eget('/api/v2/ping', Api\\V2\\Handler\\PingHandler::class, 'api.v2.ping');\n```\n\n### Namespaced version\n\nNow, using the above routing example, assuming your v1 Ping is in namespace `Api\\Handler`, you may set the namespace for v2 Ping to be `Api\\V2\\Handler` and extend the v1 handler. Any reference to services, models, other middleware will follow that namespace. Or, copy everything you want to be in the new version into a new namespace entirely.\n\n## Contributing\n\n### Docker Image\n\nThe `Dockerfile` in the repo can be used to create a lightweight image locally for running tests and other composer scripts:\n\n```sh\ndocker build --tag [your_chosen_image_name] .\n```\n\n### Run tests\n\n```sh\ndocker run --rm -it -v $(pwd):/app [your_chosen_image_name] composer test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcguyer%2Fversion-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcguyer%2Fversion-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcguyer%2Fversion-middleware/lists"}