{"action":"created","issue":{"url":"https://api.github.com/repos/composer/composer/issues/5844","repository_url":"https://api.github.com/repos/composer/composer","labels_url":"https://api.github.com/repos/composer/composer/issues/5844/labels{/name}","comments_url":"https://api.github.com/repos/composer/composer/issues/5844/comments","events_url":"https://api.github.com/repos/composer/composer/issues/5844/events","html_url":"https://github.com/composer/composer/issues/5844","id":187133696,"number":5844,"title":"Option -o does not actually optimize anything ?","user":{"login":"Taluu","id":239685,"avatar_url":"https://avatars.githubusercontent.com/u/239685?v=3","gravatar_id":"","url":"https://api.github.com/users/Taluu","html_url":"https://github.com/Taluu","followers_url":"https://api.github.com/users/Taluu/followers","following_url":"https://api.github.com/users/Taluu/following{/other_user}","gists_url":"https://api.github.com/users/Taluu/gists{/gist_id}","starred_url":"https://api.github.com/users/Taluu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Taluu/subscriptions","organizations_url":"https://api.github.com/users/Taluu/orgs","repos_url":"https://api.github.com/users/Taluu/repos","events_url":"https://api.github.com/users/Taluu/events{/privacy}","received_events_url":"https://api.github.com/users/Taluu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-03T17:15:18Z","updated_at":"2016-11-04T08:59:12Z","closed_at":"2016-11-04T08:55:05Z","body":"My `composer.json`:\r\n\r\n```json\r\n\r\n{\r\n    \"name\": \"acme/foo\",\r\n\r\n    \"autoload\": {\r\n        \"psr-4\": {\r\n            \"Acme\\\\\": [\"src/\"]\r\n        }\r\n    },\r\n\r\n    \"require\": {\r\n        \"php\": \"^7.0\",\r\n    }\r\n}\r\n```\r\n\r\nOutput of `composer diagnose`:\r\n\r\n```\r\nChecking composer.json: OK\r\nChecking platform settings: OK\r\nChecking git settings: OK\r\nChecking http connectivity to packagist: OK\r\nChecking https connectivity to packagist: OK\r\nChecking github.com rate limit: OK\r\nChecking disk free space: OK\r\nChecking pubkeys:\r\nTags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642\r\nDev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952\r\nOK\r\nChecking composer version: OK\r\n```\r\n\r\nWhen I run this command:\r\n\r\n```\r\ncomposer dump-autoload -o\r\n```\r\n\r\nI get the following output:\r\n\r\n```\r\nGenerating optimized autoload files\r\n```\r\n\r\nAnd I expected this to happen:\r\n\r\nIn the autoload_real, I expect something like this ;\r\n\r\n```php\r\n<?php\r\n//...\r\n    public static function getLoader()                                                                                        \r\n    {                                                                                                                         \r\n        if (null !== self::$loader) {                                                                                         \r\n            return self::$loader;                                                                                             \r\n        }                                                                                                                     \r\n                                                                                                                              \r\n        spl_autoload_register(array('ComposerAutoloaderInita011418f40989e9a439ce1b16d482b74', 'loadClassLoader'), true, true);\r\n        self::$loader = $loader = new \\Composer\\Autoload\\ClassLoader();                                                       \r\n        spl_autoload_unregister(array('ComposerAutoloaderInita011418f40989e9a439ce1b16d482b74', 'loadClassLoader'));          \r\n                                                                                                                              \r\n        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');                                               \r\n        if ($useStaticLoader) {                                                                                               \r\n            require_once __DIR__ . '/autoload_static.php';                                                                    \r\n                                                                                                                             \r\n            call_user_func(\\Composer\\Autoload\\ComposerStaticInita011418f40989e9a439ce1b16d482b74::getInitializer($loader));   \r\n        } else {                                                                                                                                                                                                            \r\n            $classMap = require __DIR__ . '/autoload_classmap.php';                                                           \r\n            if ($classMap) {                                                                                                  \r\n                $loader->addClassMap($classMap);                                                                              \r\n            }                                                                                                                 \r\n        }                                                                                                                     \r\n                                                                                                                              \r\n        $loader->register(true);                                                                                              \r\n                                                                                                                              \r\n        if ($useStaticLoader) {                                                                                               \r\n            $includeFiles = Composer\\Autoload\\ComposerStaticInita011418f40989e9a439ce1b16d482b74::$files;                     \r\n        } else {                                                                                                              \r\n            $includeFiles = require __DIR__ . '/autoload_files.php';                                                          \r\n        }                                                                                                                     \r\n        foreach ($includeFiles as $fileIdentifier => $file) {                                                                 \r\n            composerRequirea011418f40989e9a439ce1b16d482b74($fileIdentifier, $file);                                          \r\n        }                                                                                                                     \r\n                                                                                                                              \r\n        return $loader;                                                                                                       \r\n    }                                                                                                                         \r\n}                                                                                                                             \r\n```\r\n\r\n\r\nAnd I have this instead : \r\n\r\n```php\r\n<?php\r\n// ...\r\n    public static function getLoader()                                                                                        \r\n    {                                                                                                                         \r\n        if (null !== self::$loader) {                                                                                         \r\n            return self::$loader;                                                                                             \r\n        }                                                                                                                     \r\n                                                                                                                              \r\n        spl_autoload_register(array('ComposerAutoloaderInita011418f40989e9a439ce1b16d482b74', 'loadClassLoader'), true, true);\r\n        self::$loader = $loader = new \\Composer\\Autoload\\ClassLoader();                                                       \r\n        spl_autoload_unregister(array('ComposerAutoloaderInita011418f40989e9a439ce1b16d482b74', 'loadClassLoader'));          \r\n                                                                                                                              \r\n        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');                                               \r\n        if ($useStaticLoader) {                                                                                               \r\n            require_once __DIR__ . '/autoload_static.php';                                                                    \r\n                                                                                                                              \r\n            call_user_func(\\Composer\\Autoload\\ComposerStaticInita011418f40989e9a439ce1b16d482b74::getInitializer($loader));   \r\n        } else {                                                                                                              \r\n            $map = require __DIR__ . '/autoload_namespaces.php';                                                              \r\n            foreach ($map as $namespace => $path) {                                                                           \r\n                $loader->set($namespace, $path);                                                                              \r\n            }                                                                                                                 \r\n                                                                                                                              \r\n            $map = require __DIR__ . '/autoload_psr4.php';                                                                    \r\n            foreach ($map as $namespace => $path) {                                                                           \r\n                $loader->setPsr4($namespace, $path);                                                                          \r\n            }                                                                                                                 \r\n                                                                                                                              \r\n            $classMap = require __DIR__ . '/autoload_classmap.php';                                                           \r\n            if ($classMap) {                                                                                                  \r\n                $loader->addClassMap($classMap);                                                                              \r\n            }                                                                                                                 \r\n        }                                                                                                                     \r\n                                                                                                                              \r\n        $loader->register(true);                                                                                              \r\n                                                                                                                              \r\n        if ($useStaticLoader) {                                                                                               \r\n            $includeFiles = Composer\\Autoload\\ComposerStaticInita011418f40989e9a439ce1b16d482b74::$files;                     \r\n        } else {                                                                                                              \r\n            $includeFiles = require __DIR__ . '/autoload_files.php';                                                          \r\n        }                                                                                                                     \r\n        foreach ($includeFiles as $fileIdentifier => $file) {                                                                 \r\n            composerRequirea011418f40989e9a439ce1b16d482b74($fileIdentifier, $file);                                          \r\n        }                                                                                                                     \r\n                                                                                                                              \r\n        return $loader;                                                                                                       \r\n    }                                                                                                                         \r\n}                                                                                                                             \r\n```\r\n\r\nAs you can see, if not using the authoritative classmap, but just using `-o`, it is not optimized per se because it loads the mnecanisms for psr-* with the classmap, while it should only load the classmap, unless I read that wrong ?"},"comment":{"url":"https://api.github.com/repos/composer/composer/issues/comments/258375600","html_url":"https://github.com/composer/composer/issues/5844#issuecomment-258375600","issue_url":"https://api.github.com/repos/composer/composer/issues/5844","id":258375600,"user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"created_at":"2016-11-04T08:59:12Z","updated_at":"2016-11-04T08:59:12Z","body":"the authoritative classmap is an extra level of optimization (providing even better perf, but not suitable for dev environments where you add new classes without rebuilding the autoloader each time). Note that passing ``--classmap-authoritative`` automatically enables ``--optimize-autoloader`` too (because the classmap cannot be authoritative if it does not contain classes configured through a PSR-X location)"}}
{"actor":{"display_login":"stof"}}