feat(xb): unify DPL and HN backend, themes and registration reports

This commit is contained in:
hellcat committed 2026-10-31 18:58:37 +08:00
1 parent eb630d2caf
commit 1ded40226b
1082 files changed
+159466 -104

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Support;
use Illuminate\Foundation\Application;
use InvalidArgumentException;
final class InstanceRuntime
{
public static function configure(Application $app): void
{
$id = $_SERVER['XB_INSTANCE'] ?? $_ENV['XB_INSTANCE'] ?? getenv('XB_INSTANCE');
if ($id === false || $id === null || $id === '') return;
if (!is_string($id) || !preg_match('/\A[a-z][a-z0-9_-]{0,31}\z/D', $id)) throw new InvalidArgumentException('Invalid XB_INSTANCE');
$root = $app->basePath('instances/'.$id);
if (!is_file($root.'/.env')) throw new InvalidArgumentException('Instance environment not configured: '.$id);
$app->useEnvironmentPath($root)->loadEnvironmentFrom('.env');
$app->useStoragePath($root.'/storage');
foreach (['APP_CONFIG_CACHE'=>'config.php','APP_ROUTES_CACHE'=>'routes-v7.php','APP_EVENTS_CACHE'=>'events.php','APP_SERVICES_CACHE'=>'services.php','APP_PACKAGES_CACHE'=>'packages.php'] as $key=>$name) {
$value=$root.'/bootstrap/cache/'.$name;
$_SERVER[$key]=$_ENV[$key]=$value;putenv($key.'='.$value);
}
}
}