{"id":21965513,"url":"https://github.com/softius/resources-resolver","last_synced_at":"2026-05-16T13:07:53.710Z","repository":{"id":57054975,"uuid":"59900096","full_name":"softius/resources-resolver","owner":"softius","description":"Resolve file paths and methods","archived":false,"fork":false,"pushed_at":"2016-06-10T19:42:18.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T01:25:47.144Z","etag":null,"topics":[],"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/softius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-28T15:04:43.000Z","updated_at":"2017-09-17T12:08:19.000Z","dependencies_parsed_at":"2022-08-24T14:00:18.717Z","dependency_job_id":null,"html_url":"https://github.com/softius/resources-resolver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softius%2Fresources-resolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softius%2Fresources-resolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softius%2Fresources-resolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softius%2Fresources-resolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softius","download_url":"https://codeload.github.com/softius/resources-resolver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245022331,"owners_count":20548521,"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":[],"created_at":"2024-11-29T12:47:54.201Z","updated_at":"2026-05-16T13:07:48.688Z","avatar_url":"https://github.com/softius.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Resources Resolver\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require softius/resources-resolver\n```\n\n## Usage \n\nThe following resolvers are made available by this library.\n\n* `CallableResolver`\n* `FilenameResolver`\n\n## Usage: CallableResolver\n\nIt is possible to resolve the following inputs to the associated callable as it is demonstrated below. This works for static and non-static methods as well and it relies heavily for a Container to be provided.\n\n* `App\\GreetingController::helloAction` to `[instance of App\\GreetingController, 'helloAction']`\n* `::helloAction` to `[instance of calling class, 'helloAction']`\n* `parent::helloAction` to `[parent instance of calling class, 'helloAction']`\n* `App\\SomeClass::someStaticMethod` to `['App\\SomeClass', 'someStaticMethod']`\n\n### Resolve a non - static method\n\n``` PHP\nuse League\\Container\\Container;\nuse Softius\\ResourcesResolver\\CallableResolver;\n\n$container = new Container();\n$container-\u003eadd('App\\SomeClass');\n\n$resolver = new CallableResolver($container);\n\n$callable = $resolver-\u003eresolve('App\\SomeClass::someMethod');;\n```\n\n### Resolve a method using alias for class\n\n\n``` PHP\nuse League\\Container\\Container;\nuse Softius\\ResourcesResolver\\CallableResolver;\n\n$container = new Container();\n$container-\u003eadd('FooClass', 'App\\SomeClass');\n\n$resolver = new CallableResolver($container);\n\n$callable = $resolver-\u003eresolve('FooClass::someMethod');;\n```\n\n### Resolve a static method\n\n``` PHP\nuse Softius\\ResourcesResolver\\CallableResolver;\n\n$resolver = new CallableResolver();\n\n$callable = $resolver-\u003eresolve('App\\SomeClass::someStaticMethod');\n```\n\n### Resolve using parent or self\n\n``` PHP\nuse Softius\\ResourcesResolver\\CallableResolver;\n\nclass A\n{\n    public function hi()\n    {\n        echo 'A: Hi!';\n    }\n}\n\nclass B extends A\n{\n    public function hi()\n    {\n        echo 'B: Hi!';\n    }\n    \n    public function test()\n    {\n        $resolver = new CallableResolver();\n        $callable = $resolver-\u003eresolve('::hi');         // returns [B, hi]\n        $callable = $resolver-\u003eresolve('self::hi');     // returns [B, hi]\n        $callable = $resolver-\u003eresolve('parent::hi');   // returns [A, hi]\n    }   \n}\n```\n\n## Usage: FilenameResolver\n\n### Resolve a filename from templates directory\n\n``` PHP\ndefine('TEMPLATES_DIR', '...');\n\nuse Softius\\ResourcesResolver\\FilenameResolver; \n\n$resolver = new FilenameResolver(TEMPLATES_DIR); \n$filename = $resolver-\u003eresolve('path/to/template.php');\n```\n\nIt is also possible to omit the extension and specify a global extension for all files to be resolved, like below.\n\n``` PHP\ndefine('TEMPLATES_DIR', '...');\n\nuse Softius\\ResourcesResolver\\FilenameResolver; \n\n$resolver = new FilenameResolver(TEMPLATES_DIR); \n$resolver-\u003esetExtension('php');\n$filename = $resolver-\u003eresolve('path/to/template');\n```\n\nMany frameworks don't use the directory separator to provide a consistent look across multiple OS. The following example uses '.' as the directory separator without file extensions\n\n``` PHP\ndefine('TEMPLATES_DIR', '...');\n\nuse Softius\\ResourcesResolver\\FilenameResolver; \n\n$resolver = new FilenameResolver(TEMPLATES_DIR, '.');\n$resolver-\u003esetExtension('php');\n$filename = $resolver-\u003eresolve('path.to.template');\n```\n\n### Resolve a filename from include path\n\n``` PHP\ndefine('TEMPLATES_DIR', '...');\n\nuse Softius\\ResourcesResolver\\FilenameResolver; \n\n$resolver = new FilenameResolver(TEMPLATES_DIR);\n$resolver-\u003euseIncludePath(true);\n$filename = $resolver-\u003eresolve('path/to/file.php');\n```\n\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/softius/resources-resolver.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/softius/resources-resolver/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/softius/resources-resolver.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/softius/resources-resolver.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/softius/resources-resolver.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/softius/resources-resolver\n[link-travis]: https://travis-ci.org/softius/resources-resolver\n[link-scrutinizer]: https://scrutinizer-ci.com/g/softius/resources-resolver/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/softius/resources-resolver\n[link-downloads]: https://packagist.org/packages/softius/resources-resolver","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftius%2Fresources-resolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftius%2Fresources-resolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftius%2Fresources-resolver/lists"}