/** * Returns the classMap from composer. * Fetch it from the command dump-autoload if needed * @param bool $force Force to fetch it from the command * @return array */ protected function getClassMap($force = false) { if (empty($this->classMap) || $force) { if (Config::get('classmap_file') && !file_exists(Config::get('classmap_file')) || $force) { // Check if composer is executable or not if (is_executable(Config::get('composer'))) { exec(sprintf('%s dump-autoload --optimize --quiet --no-interaction --working-dir=%s 2>&1', escapeshellarg(Config::get('composer')), escapeshellarg(Config::get('projectPath')))); } else { exec(sprintf('%s %s dump-autoload --optimize --quiet --no-interaction --working-dir=%s 2>&1', escapeshellarg(Config::get('php')), escapeshellarg(Config::get('composer')), escapeshellarg(Config::get('projectPath')))); } } if (Config::get('classmap_file')) { $this->classMap = (require Config::get('classmap_file')); } } return $this->classMap; }
die(json_encode(array('error' => array('message' => $message)))); } if (count($argv) < 3) { die('Usage : php parser.php <dirname> <command> <args>'); } $project = $argv[1]; $command = $argv[2]; if (!isset($commands[$command])) { show_error(sprintf('Command %s not found', $command)); } // Config Config::set('composer', $config['composer']); Config::set('php', $config['php']); Config::set('projectPath', $project); // To see if it fix #19 chdir(Config::get('projectPath')); $indexDir = __DIR__ . '/../indexes/' . md5($project); if (!is_dir($indexDir)) { if (false === mkdir($indexDir, 0777, true)) { show_error('Unable to create directory ' . $indexDir); } } Config::set('indexClasses', $indexDir . '/index.classes.json'); foreach ($config['autoload'] as $conf) { $path = sprintf('%s/%s', $project, trim($conf, '/')); if (file_exists($path)) { require_once $path; break; } } foreach ($config['classmap'] as $conf) {