Skip to content

Commit

Permalink
add bin/apphost
Browse files Browse the repository at this point in the history
  • Loading branch information
Maometos committed Feb 28, 2022
1 parent 5133089 commit 438b735
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 68 deletions.
36 changes: 36 additions & 0 deletions bin/apphost
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use DevNet\System\Runtime\Launcher;

$projectFile = simplexml_load_file(__DIR__ . "/../project.phproj");
$namespace = $projectFile->properties->namespace;
$entrypoint = $projectFile->properties->entrypoint;
$packages = $projectFile->dependencies->package ?? [];

if (PHP_OS_FAMILY == 'Windows') {
$path = getenv('path');
$paths = explode(';', $path);
} else {
$path = getenv('PATH');
$paths = explode(':', $path);
}

foreach ($paths as $path) {
if (file_exists($path . '/../autoload.php')) {
require $path . '/../autoload.php';
break;
}
}

foreach ($packages as $package) {
$include = (string)$package->attributes()->include;
if (file_exists(__DIR__ . '/../' . $include)) {
require __DIR__ . '/../' . $include;
}
}

$launcher = Launcher::getLauncher();
$launcher->workspace(dirname(__DIR__));
$launcher->namespace((string)$namespace);
$launcher->entryPoint((string)$entrypoint);
$launcher->launch();
35 changes: 1 addition & 34 deletions bin/run
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
#!/usr/bin/env php
<?php

use DevNet\System\Runtime\launcher;

$projectFile = simplexml_load_file(__DIR__ . "/../project.phproj");
$namespace = $projectFile->properties->namespace;
$entrypoint = $projectFile->properties->entrypoint;
$packages = $projectFile->dependencies->package ?? [];

if (PHP_OS_FAMILY == 'Windows') {
$path = getenv('path');
$paths = explode(';', $path);
} else {
$path = getenv('PATH');
$paths = explode(':', $path);
}

foreach ($paths as $path) {
if (file_exists($path . '/../autoload.php')) {
require $path . '/../autoload.php';
break;
}
}

foreach ($packages as $package) {
$include = (string)$package->attributes()->include;
if (file_exists(__DIR__ . '/../' . $include)) {
require __DIR__ . '/../' . $include;
}
}

$launcher = launcher::getLauncher();
$launcher->workspace(dirname(__DIR__));
$launcher->namespace((string)$namespace);
$launcher->entryPoint((string)$entrypoint);
$launcher->launch();
require 'apphost';
35 changes: 1 addition & 34 deletions webroot/index.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
<?php

use DevNet\System\Runtime\launcher;

$projectFile = simplexml_load_file(__DIR__ . "/../project.phproj");
$namespace = $projectFile->properties->namespace;
$entrypoint = $projectFile->properties->entrypoint;
$packages = $projectFile->dependencies->package ?? [];

if (PHP_OS_FAMILY == 'Windows') {
$path = getenv('path');
$paths = explode(';', $path);
} else {
$path = getenv('PATH');
$paths = explode(':', $path);
}

foreach ($paths as $path) {
if (file_exists($path . '/../autoload.php')) {
require $path . '/../autoload.php';
break;
}
}

foreach ($packages as $package) {
$include = (string)$package->attributes()->include;
if (file_exists(__DIR__ . '/../' . $include)) {
require __DIR__ . '/../' . $include;
}
}

$launcher = launcher::getLauncher();
$launcher->workspace(dirname(__DIR__));
$launcher->namespace((string)$namespace);
$launcher->entryPoint((string)$entrypoint);
$launcher->launch();
require '../bin/apphost';

0 comments on commit 438b735

Please sign in to comment.