3 * Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de
5 * This file is released under the terms of the MIT license. You can find the
6 * complete text in the attached LICENSE file or online at:
8 * http://www.opensource.org/licenses/mit-license.php
11 namespace xrstf\Composer52;
13 use Composer\Repository\CompositeRepository;
14 use Composer\Script\Event;
17 public static function onPostInstallCmd(Event $event) {
18 $composer = $event->getComposer();
19 $installationManager = $composer->getInstallationManager();
20 $repoManager = $composer->getRepositoryManager();
21 $localRepo = $repoManager->getLocalRepository();
22 $package = $composer->getPackage();
23 $config = $composer->getConfig();
25 // We can't gain access to the Command's input object, so we have to look
26 // for -o / --optimize-autoloader ourselves. Sadly, neither getopt() works
27 // (always returns an empty array), nor does Symfony's Console Input, as
28 // it expects a full definition of the current command line and we can't
31 // $def = new InputDefinition(array(new InputOption('optimize', 'o', InputOption::VALUE_NONE)));
32 // $input = new ArgvInput(null, $def);
33 // var_dump($input->hasOption('o')); // "Too many arguments"
35 // $options = getopt('o', array('optimize-autoloader')); // always array()
36 // $optimize = !empty($options);
38 $args = $_SERVER['argv'];
39 $optimize = in_array('-o', $args) || in_array('-o', $args);
41 $generator = new AutoloadGenerator();
42 $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);