Skip to content

Commit 438b735

Browse files
committed
add bin/apphost
1 parent 5133089 commit 438b735

File tree

3 files changed

+38
-68
lines changed

3 files changed

+38
-68
lines changed

bin/apphost

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

bin/run

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,4 @@
11
#!/usr/bin/env php
22
<?php
33

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();
4+
require 'apphost';

webroot/index.php

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
11
<?php
22

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

0 commit comments

Comments
 (0)