{"id":14966336,"url":"https://github.com/yiisoft/aliases","last_synced_at":"2025-10-19T09:31:10.296Z","repository":{"id":35010792,"uuid":"196275583","full_name":"yiisoft/aliases","owner":"yiisoft","description":"Named paths and URLs storage","archived":false,"fork":false,"pushed_at":"2024-04-14T12:26:37.000Z","size":148,"stargazers_count":25,"open_issues_count":3,"forks_count":9,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-04-15T03:09:11.405Z","etag":null,"topics":["alias","hacktoberfest","path","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2019-07-10T21:11:46.000Z","updated_at":"2024-04-17T04:44:17.043Z","dependencies_parsed_at":"2024-04-17T04:44:05.418Z","dependency_job_id":null,"html_url":"https://github.com/yiisoft/aliases","commit_stats":{"total_commits":111,"total_committers":13,"mean_commits":8.538461538461538,"dds":"0.45945945945945943","last_synced_commit":"23a91665aeb47cc6931d695b16529d0c36716b3f"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":"yiisoft/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Faliases","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Faliases/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Faliases/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Faliases/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/aliases/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865475,"owners_count":16554151,"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":["alias","hacktoberfest","path","yii3"],"created_at":"2024-09-24T13:36:14.406Z","updated_at":"2025-10-19T09:31:10.278Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Aliases\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/aliases/v)](https://packagist.org/packages/yiisoft/aliases)\n[![Total Downloads](https://poser.pugx.org/yiisoft/aliases/downloads)](https://packagist.org/packages/yiisoft/aliases)\n[![Build status](https://github.com/yiisoft/aliases/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/aliases/actions/workflows/build.yml)\n[![Code Coverage](https://codecov.io/gh/yiisoft/aliases/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/aliases)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https://badge-api.stryker-mutator.io/github.com/yiisoft/aliases/master)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/aliases/master)\n[![Static analysis](https://github.com/yiisoft/aliases/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/yiisoft/aliases/actions/workflows/static.yml?query=branch%3Amaster)\n[![type-coverage](https://shepherd.dev/github/yiisoft/aliases/coverage.svg)](https://shepherd.dev/github/yiisoft/aliases)\n\nThe package aim is to store path aliases, i.e. short name representing a long path (a file path, a URL, etc.).\nPath alias value may have another value as its part. For example, `@vendor` may store path to `vendor` directory\nwhile `@bin` may store `@vendor/bin`.\n\n## Requirements\n\n- PHP 8.1 or higher.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/aliases\n```\n\n## General usage\n\nA path alias must start with the character '@' so that it can be easily differentiated from non-alias paths.\n\n```php\nuse Yiisoft\\Aliases\\Aliases;\n\n$aliases = new Aliases([\n    '@root' =\u003e __DIR__,\n]);\n$aliases-\u003eset('@vendor', '@root/vendor');\n$aliases-\u003eset('@bin', '@vendor/bin');\n\necho $aliases-\u003eget('@bin/phpunit');\n```\n\nThe code about would output \"/path/to/vendor/bin/phpunit\".\n\nNote that `set()` method does not check if the given path exists or not. All it does is to associate the alias with\nthe path.\n\nThe path could be:\n\n- a directory or a file path (e.g. `/tmp`, `/tmp/main.txt`)\n- a URL (e.g. `https://www.yiiframework.com`)\n- a path alias (e.g. `@yii/base`). It will be resolved on {@see get()} call.\n\nAny trailing `/` and `\\` characters in the given path will be trimmed.\n\nTo bulk translate path aliases into actual paths use `getArray()` method:\n\n```php\n$aliases = new Aliases([\n    '@root' =\u003e '/my/app',\n]);\n\n// Value will be ['src' =\u003e '/my/app/src', 'tests' =\u003e '/my/app/tests']\n$directories = $aliases-\u003egetAll(['src' =\u003e '@root/src', 'tests' =\u003e '@root/tests']);\n```\n\n### Alias priorities\n\nIn case multiple aliases are registered with same root (prefix), then the most specific has precedence:\n\n```php\nuse Yiisoft\\Aliases\\Aliases;\n\n$aliases = new Aliases([\n    '@vendor' =\u003e __DIR__ . '/vendor',\n    '@vendor/test' =\u003e '/special/location'    \n]);\necho $aliases-\u003eget('@vendor/test');\n```\n\nThat would output `/special/location` since `@vendor/test` is more specific match than `@vendor`.\n\n### Alias removal\n\nIf you need to remove alias runtime:\n\n```php\nuse Yiisoft\\Aliases\\Aliases;\n\n$aliases = new Aliases([\n    '@root' =\u003e __DIR__,\n]);\n$aliases-\u003eremove('@root');\n```\n\n### Alias references\n\nThe package provides `AliasReference` class that implements `ReferenceInterface` from\n[Yii Definition](https://github.com/yiisoft/definitions). It allows you to create references to aliases\nthat will be resolved at runtime:\n\n```php\n// Create a reference to an alias\n$reference = \\Yiisoft\\Aliases\\AliasReference::to('@public/assets');\n\n// The reference will be resolved when needed\n$configPath = $reference-\u003eresolve($container);\n```\n\nThis is particularly useful in dependency injection configurations where you want to inject resolved paths\nbut the aliases are not available at configuration time.\n\n## Documentation\n\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.\nYou may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Aliases is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Faliases","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Faliases","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Faliases/lists"}