Skip to content

Commit 15fb7f7

Browse files
committed
added bin/run command
1 parent efa7f90 commit 15fb7f7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

bin/run

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use DevNet\System\Runtime\launcher;
5+
6+
$projectFile = simplexml_load_file(__DIR__ . "/../project.phproj");
7+
$namespace = $projectFile->properties->namespace;
8+
$entrypoint = $projectFile->properties->entrypoint;
9+
$packages = $projectFile->dependencies->package ?? [];
10+
11+
if (PHP_OS_FAMILY == 'Windows') {
12+
$path = getenv('path');
13+
$paths = explode(';', $path);
14+
} else {
15+
$path = getenv('PATH');
16+
$paths = explode(':', $path);
17+
}
18+
19+
foreach ($paths as $path) {
20+
if (file_exists($path . '/../autoload.php')) {
21+
require $path . '/../autoload.php';
22+
break;
23+
}
24+
}
25+
26+
foreach ($packages as $package) {
27+
$include = (string)$package->attributes()->include;
28+
if (file_exists(__DIR__ . '/../' . $include)) {
29+
require __DIR__ . '/../' . $include;
30+
}
31+
}
32+
33+
$launcher = launcher::getLauncher();
34+
$launcher->workspace(dirname(__DIR__));
35+
$launcher->namespace((string)$namespace);
36+
$launcher->entryPoint((string)$entrypoint);
37+
$launcher->launch();

0 commit comments

Comments
 (0)