public static function processBeforeCommandLoad(Context $context, $args) { // just in case! $se = $context->stderr; foreach ($args as $path) { if (!is_dir($path)) { $se->output($context->errorStyle, $context->errorPrefix); $se->outputLine(null, 'directory "' . $path . '" not found'); return 1; } $context->addSearchPath($path); \__gwc_autoload_alsoSearch(\realpath($path)); } // we do not want phix to terminate yet return null; }
continue; } require $fileToLoad; return TRUE; } // if we get here, we could not find the requested file // we do not die() or throw an exception, because there may // be other autoload functions also registered return FALSE; } function __gwc_autoload_alsoSearch($dir) { $dir = realpath($dir); // check to make sure that $dir is not already in the path $pathToSearch = explode(PATH_SEPARATOR, get_include_path()); foreach ($pathToSearch as $dirToSearch) { $dirToSearch = realpath($dirToSearch); if ($dirToSearch == $dir) { // we have found it // remove it from the list $key = key($pathToSearch); unset($pathToSearch[$key]); } } // add the new directory to the front of the path set_include_path($dir . PATH_SEPARATOR . implode(PATH_SEPARATOR, $pathToSearch)); } spl_autoload_register('__gwc_autoload'); // assume that we are at the top of a vendor tree to load from __gwc_autoload_alsoSearch(__DIR__);