{"id":24974457,"url":"https://github.com/rize/uritemplate","last_synced_at":"2026-05-23T08:01:16.241Z","repository":{"id":15553448,"uuid":"18288517","full_name":"rize/UriTemplate","owner":"rize","description":"PHP URI Template (RFC 6570) supports both URI expansion \u0026 extraction","archived":false,"fork":false,"pushed_at":"2025-12-02T15:20:15.000Z","size":116,"stargazers_count":420,"open_issues_count":1,"forks_count":15,"subscribers_count":9,"default_branch":"master","last_synced_at":"2026-04-28T11:46:05.060Z","etag":null,"topics":["expansion","extraction","php","rfc-6570","uri-template"],"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/rize.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"rezigned","open_collective":"rize-uri-template","custom":"https://www.paypal.me/rezigned"}},"created_at":"2014-03-31T09:42:43.000Z","updated_at":"2026-03-14T09:17:03.000Z","dependencies_parsed_at":"2024-03-17T05:42:38.762Z","dependency_job_id":null,"html_url":"https://github.com/rize/UriTemplate","commit_stats":{"total_commits":61,"total_committers":16,"mean_commits":3.8125,"dds":0.7049180327868853,"last_synced_commit":"b36fe7dafc28c8bfd45ba4149ef60c59041b1e30"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/rize/UriTemplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rize%2FUriTemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rize%2FUriTemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rize%2FUriTemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rize%2FUriTemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rize","download_url":"https://codeload.github.com/rize/UriTemplate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rize%2FUriTemplate/sbom","scorecard":{"id":777734,"data":{"date":"2025-08-11","repo":{"name":"github.com/rize/UriTemplate","commit":"56f374a9a42c7c3998f8b55b6b21b224de90c58b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.2,"checks":[{"name":"Code-Review","score":5,"reason":"Found 13/23 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T04:03:22.958Z","repository_id":15553448,"created_at":"2025-08-23T04:03:22.958Z","updated_at":"2025-08-23T04:03:22.958Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33387656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"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":["expansion","extraction","php","rfc-6570","uri-template"],"created_at":"2025-02-03T20:04:14.347Z","updated_at":"2026-05-23T08:01:16.215Z","avatar_url":"https://github.com/rize.png","language":"PHP","funding_links":["https://github.com/sponsors/rezigned","https://opencollective.com/rize-uri-template","https://www.paypal.me/rezigned","https://opencollective.com/rize-uri-template/contribute","https://opencollective.com/rize-uri-template/organization/0/website","https://opencollective.com/rize-uri-template/organization/1/website","https://opencollective.com/rize-uri-template/organization/2/website","https://opencollective.com/rize-uri-template/organization/3/website","https://opencollective.com/rize-uri-template/organization/4/website","https://opencollective.com/rize-uri-template/organization/5/website","https://opencollective.com/rize-uri-template/organization/6/website","https://opencollective.com/rize-uri-template/organization/7/website","https://opencollective.com/rize-uri-template/organization/8/website","https://opencollective.com/rize-uri-template/organization/9/website"],"categories":[],"sub_categories":[],"readme":"# PHP URI Template\n\nThis is a URI Template implementation in PHP based on [RFC 6570 URI Template](http://tools.ietf.org/html/rfc6570). In addition to URI expansion, it also supports URI extraction (used by [Google Cloud Core](https://github.com/googleapis/google-cloud-php-core) and [Google Cloud Client Library](https://github.com/googleapis/google-cloud-php)).\n\n![CI](https://github.com/rize/UriTemplate/workflows/CI/badge.svg) [![Total Downloads](https://poser.pugx.org/rize/uri-template/downloads)](https://packagist.org/packages/rize/uri-template) [![Latest Stable Version](https://poser.pugx.org/rize/uri-template/v)](https://packagist.org/packages/rize/uri-template) [![PHP Version Require](https://poser.pugx.org/rize/uri-template/require/php)](https://packagist.org/packages/rize/uri-template)\n\n\u003e [!NOTE]\n\u003e\n\u003e Due to the deprecation of implictly nullable parameter types in [PHP 8.4](https://wiki.php.net/rfc/deprecate-implicitly-nullable-types), we must introduce breaking change by adding explicit nullable types (`?T`) which requires PHP 7.1+.\n\u003e\n\u003e As a result, version [0.4.0](https://github.com/rize/UriTemplate/releases/tag/0.4.0) and later will no longer support PHP versions below 8.1.\n\n## Usage\n\n### Expansion\n\nA very simple usage (string expansion).\n\n```php\n\u003c?php\n\nuse Rize\\UriTemplate;\n\n$uri = new UriTemplate();\n$uri-\u003eexpand('/{username}/profile', ['username' =\u003e 'john']);\n\n\u003e\u003e '/john/profile'\n```\n\n`Rize\\UriTemplate` supports all `Expression Types` and `Levels` specified by RFC6570.\n\n```php\n\u003c?php\n\nuse Rize\\UriTemplate;\n\n$uri = new UriTemplate();\n$uri-\u003eexpand('/search/{term:1}/{term}/{?q*,limit}', [\n    'term'  =\u003e 'john',\n    'q'     =\u003e ['a', 'b'],\n    'limit' =\u003e 10,\n])\n\n\u003e\u003e '/search/j/john/?q=a\u0026q=b\u0026limit=10'\n```\n\n#### `/` Path segment expansion\n\n```php\n\u003c?php\n\nuse Rize\\UriTemplate;\n\n$uri = new UriTemplate();\n$uri-\u003eexpand('http://{host}{/segments*}/{file}{.extensions*}', [\n    'host'       =\u003e 'www.host.com',\n    'segments'   =\u003e ['path', 'to', 'a'],\n    'file'       =\u003e 'file',\n    'extensions' =\u003e ['x', 'y'],\n]);\n\n\u003e\u003e 'http://www.host.com/path/to/a/file.x.y'\n```\n\n`Rize\\UriTemplate` accepts `base-uri` as a 1st argument and `default params` as a 2nd argument. This is very useful when you're working with API endpoint.\n\nTake a look at real world example.\n\n```php\n\u003c?php\n\nuse Rize\\UriTemplate;\n\n$uri = new UriTemplate('https://api.twitter.com/{version}', ['version' =\u003e 1.1]);\n$uri-\u003eexpand('/statuses/show/{id}.json', ['id' =\u003e '210462857140252672']);\n\n\u003e\u003e https://api.twitter.com/1.1/statuses/show/210462857140252672.json\n```\n\n### Extraction\n\nIt also supports URI Extraction (extract all variables from URI). Let's take a look at the example.\n\n```php\n\u003c?php\n\nuse Rize\\UriTemplate;\n\n$uri = new UriTemplate('https://api.twitter.com/{version}', ['version' =\u003e 1.1]);\n\n$params = $uri-\u003eextract('/search/{term:1}/{term}/{?q*,limit}', '/search/j/john/?q=a\u0026q=b\u0026limit=10');\n\n\u003e\u003e print_r($params);\n(\n    [term:1] =\u003e j\n    [term] =\u003e john\n    [q] =\u003e Array\n        (\n            [0] =\u003e a\n            [1] =\u003e b\n        )\n\n    [limit] =\u003e 10\n)\n```\n\nNote that in the example above, result returned by `extract` method has an extra keys named `term:1` for `prefix` modifier. This key was added just for our convenience to access prefix data.\n\n#### `strict` mode\n\n```php\n\u003c?php\n\nuse Rize\\UriTemplate;\n\n$uri = new UriTemplate();\n$uri-\u003eextract($template, $uri, $strict = false)\n```\n\nNormally `extract` method will try to extract vars from a uri even if it's partially matched. For example\n\n```php\n\u003c?php\n\nuse Rize\\UriTemplate;\n\n$uri = new UriTemplate();\n$params = $uri-\u003eextract('/{?a,b}', '/?a=1')\n\n\u003e\u003e print_r($params);\n(\n    [a] =\u003e 1\n    [b] =\u003e null\n)\n```\n\nWith `strict mode`, it will allow you to extract uri only when variables in template are fully matched with given uri.\n\nWhich is useful when you want to determine whether the given uri is matched against your template or not (in case you want to use it as routing service).\n\n```php\n\u003c?php\n\nuse Rize\\UriTemplate;\n\n$uri = new UriTemplate();\n\n// Note that variable `b` is absent in uri\n$params = $uri-\u003eextract('/{?a,b}', '/?a=1', true);\n\n\u003e\u003e\u003e null\n\n// Now we give `b` some value\n$params = $uri-\u003eextract('/{?a,b}', '/?a=1\u0026b=2', true);\n\n\u003e\u003e\u003e print_r($params)\n(\n  [a] =\u003e 1\n  [b] =\u003e 2\n)\n```\n\n#### Array modifier `%`\n\nBy default, RFC 6570 only has 2 types of operators `:` and `*`. This `%` array operator was added to the library because current spec can't handle array style query e.g. `list[]=a` or `key[user]=john`.\n\nExample usage for `%` modifier\n\n```php\n\u003c?php\n\n$uri-\u003eexpand('{?list%,keys%}', [\n    'list' =\u003e [\n        'a', 'b',\n    ),\n    'keys' =\u003e [\n        'a' =\u003e 1,\n        'b' =\u003e 2,\n    ),\n]);\n\n// '?list[]=a\u0026list[]=b\u0026keys[a]=1\u0026keys[b]=2'\n\u003e\u003e '?list%5B%5D=a\u0026list%5B%5D=b\u0026keys%5Ba%5D=1\u0026keys%5Bb%5D=2'\n\n// [] get encoded to %5B%5D i.e. '?list[]=a\u0026list[]=b\u0026keys[a]=1\u0026keys[b]=2'\n$params = $uri-\u003eextract('{?list%,keys%}', '?list%5B%5D=a\u0026list%5B%5D=b\u0026keys%5Ba%5D=1\u0026keys%5Bb%5D=2', )\n\n\u003e\u003e print_r($params);\n(\n    [list] =\u003e Array\n        (\n            [0] =\u003e a\n            [1] =\u003e b\n        )\n\n    [keys] =\u003e Array\n        (\n            [a] =\u003e 1\n            [b] =\u003e 2\n        )\n)\n```\n\n## Installation\n\nUsing `composer`\n\n```\n{\n    \"require\": {\n        \"rize/uri-template\": \"~0.3\"\n    }\n}\n```\n\n### Changelogs\n\n* **0.2.0** Add a new modifier `%` which allows user to use `list[]=a\u0026list[]=b` query pattern.\n* **0.2.1** Add nested array support for `%` modifier\n* **0.2.5** Add strict mode support for `extract` method\n* **0.3.0** Improve code quality + RFC3986 support for `extract` method by @Maks3w\n* **0.3.1** Improve `extract` method to parse two or more adjacent variables separated by dot by @corleonis\n* **0.4.0** Fixes the deprecation of implicitly nullable parameter types introduced in PHP 8.4. This version requires PHP 8.1 or later.\n\n## Contributors\n\n### Code Contributors\n\nThis project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].\n\u003ca href=\"https://github.com/rize/UriTemplate/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n### Financial Contributors\n\nBecome a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/rize-uri-template/contribute)]\n\n#### Individuals\n\n\u003ca href=\"https://opencollective.com/rize-uri-template\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/individuals.svg?width=890\"\u003e\u003c/a\u003e\n\n#### Organizations\n\nSupport this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/rize-uri-template/contribute)]\n\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/0/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/1/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/2/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/3/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/4/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/5/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/6/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/7/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/8/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rize-uri-template/organization/9/website\"\u003e\u003cimg src=\"https://opencollective.com/rize-uri-template/organization/9/avatar.svg\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frize%2Furitemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frize%2Furitemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frize%2Furitemplate/lists"}