{"id":20776786,"url":"https://github.com/phpactor/class-to-file","last_synced_at":"2025-04-30T18:09:32.538Z","repository":{"id":21442893,"uuid":"92763335","full_name":"phpactor/class-to-file","owner":"phpactor","description":"Transform class names to file names and vice-versa","archived":false,"fork":false,"pushed_at":"2024-01-26T08:23:14.000Z","size":119,"stargazers_count":11,"open_issues_count":5,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T18:09:26.054Z","etag":null,"topics":["composer","phpactor"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"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/phpactor.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-29T18:00:12.000Z","updated_at":"2024-10-27T12:48:21.000Z","dependencies_parsed_at":"2024-06-18T19:47:33.667Z","dependency_job_id":"0ad5c884-8a43-4291-a9c0-8acf835cd1a0","html_url":"https://github.com/phpactor/class-to-file","commit_stats":{"total_commits":87,"total_committers":7,"mean_commits":"12.428571428571429","dds":0.08045977011494254,"last_synced_commit":"290dabd216a5486c3faff32e5f84742e6c038108"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpactor%2Fclass-to-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpactor%2Fclass-to-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpactor%2Fclass-to-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpactor%2Fclass-to-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpactor","download_url":"https://codeload.github.com/phpactor/class-to-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758170,"owners_count":21638989,"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":["composer","phpactor"],"created_at":"2024-11-17T13:11:46.886Z","updated_at":"2025-04-30T18:09:32.515Z","avatar_url":"https://github.com/phpactor.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Class To File Transformer\n=========================\n\n![CI](https://github.com/phpactor/class-to-file/workflows/CI/badge.svg)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpactor/class-to-file/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phpactor/class-to-file/?branch=master)\n\nThis library provides facilities to guess/transform class names to files paths\nand vice-versa.\n\nIt uses the composer autoload to guess the best candidates using **PSR-0** and\n**PSR-4**.\n\nUsage\n-----\n\n```php\n// require the composer autoloader for the class you want to investigate\n$autoloader = require(__DIR__ . '/vendor/autoload.php');\n\n// for file candidates\n$converter = ClassFileConverter::fromComposerAutoloader($autoloader);\n$candidates = $classToFile-\u003eclassToFileCandidates(ClassName::fromString('Foobar\\\\Barfoo\\\\MyClass'));\n\necho (string) $candidates-\u003eempty(); // return true if there are no candidates\necho (string) $candidates-\u003ebest(); // path to the \"best\" candidate\n\n// or for class candidates\n$candidates = $classToFile-\u003efileToClassCandidates(FilePath::fromString('lib/Foobar/BarFoo/MyClass.php'));\n```\n\nDoesn't composer provide file paths for classes?\n------------------------------------------------\n\nYes it does, but only if the class **exists**. One of the purposes of this\nclass is to be able to determine a file path for a class which may not exist\n(for example to generate a class in a new file).\n\nYou may also want to do this and not pollute your autoloading environment\n(unfortunately this library currently [does pollute the\nautoloader](https://github.com/dantleech/class-to-file/issues/3), but it can\nbe avoided in the future.\n\nWhy would you want to determine the class from a filename?\n----------------------------------------------------------\n\nGlad you asked! This is can be useful when you want to generate\nan empty class in an empty file.\n\nWhen one autoloader isn't enough\n--------------------------------\n\nIn some exceptional cases you may have a project which has more than one\ncomposer autoloader, this is supported through the `ChainFileToClass` and\n`ChainClassToFile` classes, or most simply through the *facade*:\n\n```php\n$converter = ClassFileConverter::fromComposerAutoloaders([ $autoloader1, $autoloader2 ]);\n```\n\nContributing\n------------\n\nThis package is open source and welcomes contributions! Feel free to open a\npull request on this repository.\n\nSupport\n-------\n\n- Create an issue on the main [Phpactor](https://github.com/phpactor/phpactor) repository.\n- Join the `#phpactor` channel on the Slack [Symfony Devs](https://symfony.com/slack-invite) channel.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpactor%2Fclass-to-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpactor%2Fclass-to-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpactor%2Fclass-to-file/lists"}