/** * 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; }
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) { $path = sprintf('%s/%s', $project, trim($conf, '/')); if (file_exists($path)) { Config::set('classmap_file', $path); break; } } $new = new $commands[$command](); $args = array_slice($argv, 3); foreach ($args as &$arg) { $arg = str_replace('\\\\', '\\', $arg); } $data = $new->execute($args); if (false === ($encoded = json_encode($data))) { echo json_encode(array()); } else { echo $encoded; }