22
33use DevNet\System\Runtime\Launcher;
44
5- $projectFile = simplexml_load_file(__DIR__ . "/../project.phproj");
6- $namespace = $projectFile->properties->namespace;
7- $entrypoint = $projectFile->properties->entrypoint;
8- $packages = $projectFile->dependencies->package ?? [];
9-
5+ // get the path environment variable
106if (PHP_OS_FAMILY == 'Windows') {
11- $path = getenv('path');
12- $paths = explode(';', $path);
7+ $paths = explode(';', getenv('path'));
138} else {
14- $path = getenv('PATH');
15- $paths = explode(':', $path);
9+ $paths = explode(':', getenv('PATH'));
1610}
1711
12+ // search and load global composer autoload
1813foreach ($paths as $path) {
1914 if (file_exists($path . '/../autoload.php')) {
2015 require $path . '/../autoload.php';
2116 break;
2217 }
2318}
2419
25- foreach ($packages as $package) {
26- $include = (string)$package->attributes()->include;
27- if (file_exists(__DIR__ . '/../' . $include)) {
28- require __DIR__ . '/../' . $include;
29- }
20+ $root = dirname(__FILE__, 2);
21+ // load local composer autoload
22+ if (file_exists($root . '/vendor/autoload.php')) {
23+ require $root . '/vendor/autoload.php';
3024}
3125
32- $launcher = Launcher::getLauncher();
33- $launcher->workspace(dirname(__DIR__));
34- $launcher->namespace((string)$namespace);
35- $launcher->entryPoint((string)$entrypoint);
36- $launcher->launch();
26+ // get the console arguments without command name
27+ $args = $GLOBALS['argv'] ?? [];
28+ array_shift($args);
29+
30+ // initialize and launch the application
31+ $launcher = Launcher::initialize($root.'/project.proj');
32+ $launcher->launch($args);
0 commit comments