{"id":24016352,"url":"https://github.com/decodelabs/singularity","last_synced_at":"2025-04-15T14:07:35.081Z","repository":{"id":204362001,"uuid":"711602456","full_name":"decodelabs/singularity","owner":"decodelabs","description":"Consolidated URI parsing and resolving for PHP","archived":false,"fork":false,"pushed_at":"2025-04-14T08:49:34.000Z","size":54,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-14T09:46:27.794Z","etag":null,"topics":["php","uri","url"],"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/decodelabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2023-10-29T19:00:30.000Z","updated_at":"2025-04-14T08:49:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"73a3959a-3404-447e-a12f-ab392236b8c7","html_url":"https://github.com/decodelabs/singularity","commit_stats":null,"previous_names":["decodelabs/singularity"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fsingularity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fsingularity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fsingularity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fsingularity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decodelabs","download_url":"https://codeload.github.com/decodelabs/singularity/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860125,"owners_count":21173339,"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":["php","uri","url"],"created_at":"2025-01-08T08:49:02.864Z","updated_at":"2025-04-15T14:07:35.074Z","avatar_url":"https://github.com/decodelabs.png","language":"PHP","readme":"# Singularity\n\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/singularity?style=flat)](https://packagist.org/packages/decodelabs/singularity)\n[![Latest Version](https://img.shields.io/packagist/v/decodelabs/singularity.svg?style=flat)](https://packagist.org/packages/decodelabs/singularity)\n[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/singularity.svg?style=flat)](https://packagist.org/packages/decodelabs/singularity)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/singularity/integrate.yml?branch=develop)](https://github.com/decodelabs/singularity/actions/workflows/integrate.yml)\n[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true\u0026style=flat)](https://github.com/phpstan/phpstan)\n[![License](https://img.shields.io/packagist/l/decodelabs/singularity?style=flat)](https://packagist.org/packages/decodelabs/singularity)\n\n### Consolidated URI parsing and resolving\n\nSingularity provides a unified interface for parsing and resolving URIs, PSR-7 URLs and file paths.\n\n---\n\n## Installation\n\nInstall via Composer:\n\n```bash\ncomposer require decodelabs/singularity\n```\n\n## Usage\n\nParse and normalize URIs:\n\n```php\nuse DecodeLabs\\Singularity;\n\ndd(\n    // ::uri() will parse any valid URI\n    Singularity::uri('mailto:info@example.com'),\n\n    // ::url() will parse any valid URL\n    Singularity::url('http://user:pass@www.example.com:8080/resource/page.html?param1=value1\u0026param2=value2#section1'),\n    Singularity::url('ftp://ftp.example.com/files/document.pdf'),\n    Singularity::url('mailto:user@example.com?subject=Hello\u0026body=Hi%20there')-\u003egetEmailAddress(),\n    Singularity::url('tel:+1-816-555-1212'),\n\n    // ::urn() will parse any valid URN\n    Singularity::urn('urn:isbn:0-486-27557-4'),\n    Singularity::urn('urn:ietf:rfc:3986')-\u003egetNamespace(), // ietf\n    Singularity::urn('urn:oid:2.16.840')-\u003egetIdentifier(), // 2.16.840\n);\n```\n\nParse query strings to \u003ccode\u003eTree\u003c/code\u003e:\n\n```php\nuse DecodeLabs\\Singularity;\n\n$url = Singularity::uri('http://www.example.com?param1=value1\u0026param2=value2');\n$tree = $url-\u003eparseQuery();\necho $tree-\u003eparam2-\u003eas('string'); // value2\n\n// Update query\n$newUrl = $url-\u003ewithQuery(function($tree, $url) {\n    $tree-\u003eparam2 = 'newValue2';\n    $tree-\u003eparam3 = 'value3';\n    return $tree;\n});\n```\n\nParse and normalize file paths:\n\n```php\nuse DecodeLabs\\Singularity;\n\ndd(\n    // ::path() will parse any valid file path\n    Singularity::path('/path/to/file.txt'),\n    Singularity::path('C:\\path\\to\\file.txt'),\n    Singularity::path('file:///path/to/file.txt'),\n    Singularity::path('file://C:/path/to/file.txt'),\n\n    // ::canonicalPath() will parse any valid file path and normalize it\n    Singularity::canonicalPath('/path/to/inner/./directory/../../file.txt'), // /path/to/file.txt\n);\n\n$url = Singularity::uri('http://www.example.com?param1=value1\u0026param2=value2');\n$url-\u003ewithPath(function($path) {\n    $path-\u003esetFileName('file.txt');\n    return $path;\n});\n```\n\n## Licensing\n\nSingularity is licensed under the proprietary License. See [LICENSE](./LICENSE) for the full license text.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Fsingularity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecodelabs%2Fsingularity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Fsingularity/lists"}