Skip to content

Commit 112ebdf

Browse files
committed
update template project
rename project.phproj to project.proj change project.proj data structure reconstruct apphost
1 parent 64c3b60 commit 112ebdf

File tree

3 files changed

+21
-29
lines changed

3 files changed

+21
-29
lines changed

template/bin/apphost

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,31 @@
22

33
use 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
106
if (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
1813
foreach ($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);

template/project.phproj

Lines changed: 0 additions & 10 deletions
This file was deleted.

template/project.proj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<Project>
3+
<Properties>
4+
<EntryPoint>Application\Program</EntryPoint>
5+
</Properties>
6+
</Project>

0 commit comments

Comments
 (0)