Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Scans the Composer namespace mappings to obtain the correct
* paths of packages that use psr-0 with target-dir.
*
* @see https://getcomposer.org/doc/04-schema.md#target-dir
* {
* "autoload": {
* "psr-0": { "Symfony\\Component\\Finder\\": "" }
* },
* "target-dir": "Symfony/Component/Finder"
* }
*
* Usage:
* php ede-php-autoload-list-namespaces.php vendor/composer/autoload_namespaces.php
*/
$autoloadInformation = require $_SERVER['argv'][1];
echo array_reduce(array_map(function ($prefix, $directories) {
return [$prefix, $directories];
}, array_keys($autoloadInformation), $autoloadInformation), function ($list, $package) {
list($prefix, $directories) = $package;
$prefix = addslashes($prefix);
$directory = array_pop($directories);
return $list . "(\"{$prefix}\" . \"{$directory}\") ";
}, "(") . ")";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.