{"id":18929380,"url":"https://github.com/thecodingmachine/classname-mapper","last_synced_at":"2025-10-10T18:17:26.266Z","repository":{"id":57020118,"uuid":"50676466","full_name":"thecodingmachine/classname-mapper","owner":"thecodingmachine","description":"Provides a way to find in which PHP files a class will be looked upon.","archived":false,"fork":false,"pushed_at":"2020-01-23T08:38:22.000Z","size":13,"stargazers_count":11,"open_issues_count":2,"forks_count":3,"subscribers_count":6,"default_branch":"1.1","last_synced_at":"2025-08-18T00:38:19.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-29T16:49:36.000Z","updated_at":"2023-11-11T00:19:25.000Z","dependencies_parsed_at":"2022-08-22T20:40:28.831Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/classname-mapper","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/classname-mapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fclassname-mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fclassname-mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fclassname-mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fclassname-mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/classname-mapper/tar.gz/refs/heads/1.1","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fclassname-mapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271755444,"owners_count":24815408,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-08T11:32:15.727Z","updated_at":"2025-10-10T18:17:21.227Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/mouf/classname-mapper/v/stable)](https://packagist.org/packages/mouf/classname-mapper)\n[![Total Downloads](https://poser.pugx.org/mouf/classname-mapper/downloads)](https://packagist.org/packages/mouf/classname-mapper)\n[![Latest Unstable Version](https://poser.pugx.org/mouf/classname-mapper/v/unstable)](https://packagist.org/packages/mouf/classname-mapper)\n[![License](https://poser.pugx.org/mouf/classname-mapper/license)](https://packagist.org/packages/mouf/classname-mapper)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thecodingmachine/classname-mapper/badges/quality-score.png?b=1.0)](https://scrutinizer-ci.com/g/thecodingmachine/classname-mapper/?branch=1.0)\n[![Build Status](https://travis-ci.org/thecodingmachine/classname-mapper.svg?branch=1.0)](https://travis-ci.org/thecodingmachine/classname-mapper)\n[![Coverage Status](https://coveralls.io/repos/thecodingmachine/classname-mapper/badge.svg?branch=1.0\u0026service=github)](https://coveralls.io/github/thecodingmachine/classname-mapper?branch=1.0)\n\n\nClassName mapper\n================\n\nWhat is it?\n-----------\n\nSome packages generate PHP classes. When a package generates a class, it needs to know in which directory to put the PHP \nfile, so that the class can be autoloaded by the autoloader. \nThis package is here to help you find in which directory to write your PHP file.\n\nThis package contains a simple `ClassNameMapper` PHP class.\n\nThis class will map a fully qualified class name (FQCN) to one or many possible file names according to PSR-0 or PSR-4 rules defined in your `composer.json` file.\n\nSo you pass the `ClassNameMapper` a FQCN, and it gives you back a list of file paths that will be checked by the Composer autoloader.\n\nThis is very useful in case you want to generate PHP classes, and you don't know where to write those classes.\n\nSample\n------\n\nImagine your `composer.json` looks like this:\n\n```json\n{\n    \"require\" : {\n        \"mouf/classname-mapper\": \"~1.0\"\n    },\n    \"autoload\" : {\n        \"psr-4\" : {\n            \"Acme\\\\\" : \"src/\"\n        }\n    }\n}\n```\n\nNow, let's say you want to create a `Acme\\Controller\\MyController` class. Where should you put the class?\nTo a PHP developer, it is obvious the class will go in `src/Controller/MyController.php`.\nTo a PHP program, it is a tricky problem. The `ClassNameMapper` is here to solve the problem:\n\n```php\nuse Mouf\\Composer\\ClassNameMapper;\n\n// This will create a mapper from your root composer file.\n$mapper = ClassNameMapper::createFromComposerFile();\n\n$files = $mapper-\u003egetPossibleFileNames('Acme\\Controller\\MyController');\n// $files == [\"src/Controller/MyController.php\"];\n```\n\nYou can also query the `ClassNameMapper` for a list of all namespaces that are configured in your `composer.json` file:\n \n```php\n$namespaces = $mapper-\u003egetManagedNamespaces();\n// $namespaces == [\"Acme\\\\\"];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fclassname-mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fclassname-mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fclassname-mapper/lists"}