Files
SGF/scripts/sgf-single-bootstrap.php
2026-11-11 09:00:17 +02:00

20 lines
2.1 KiB
PHP

<?php
// Shared CLI harness for the TWO pre-existing books, never provisioning a database/server.
$repo=dirname(__DIR__);$book??='regression';
if(!in_array($book,['regression','8085'],true))throw new LogicException('Known installation only');
$run=json_decode(file_get_contents('C:/laragon/data/sgf-tempo/run/modular-regression-current.json'),true);
$tag=$book==='8085'?'cc50a276c10c':'b4093c6f6707';
$s=json_decode(file_get_contents($run['root'].'/private/receipt-composition-'.$tag.'/state.json'),true);
if($run['id']!=='2576427d1939'||$s['tag']!==$tag||($book==='8085'&&!($s['singleInstallation']??false)))throw new LogicException('Physical composition changed');
$work=$s['root'].'/single-integration/'.date('Ymd-His').'-'.bin2hex(random_bytes(4));mkdir($work,0700,true);
foreach($s['env'] as $key=>$value)if(preg_match('/^(APP_|DB_|SGF_|SESSION_|CACHE_|QUEUE_|BCRYPT_)/',$key)){putenv($key.'='.$value);$_ENV[$key]=$value;$_SERVER[$key]=$value;}
foreach(['APP_BASE_PATH'=>$repo,'APP_CONFIG_CACHE'=>$work.'/config.php','APP_ROUTES_CACHE'=>$work.'/routes.php','APP_SERVICES_CACHE'=>$work.'/services.php','APP_PACKAGES_CACHE'=>$work.'/packages.php','SESSION_DRIVER'=>'array','CACHE_STORE'=>'array'] as $key=>$value){putenv($key.'='.$value);$_ENV[$key]=$value;$_SERVER[$key]=$value;}
require $repo.'/vendor/autoload.php';$app=require $repo.'/bootstrap/app.php';$app->addAbsoluteCachePathPrefix('C:');$app->useStoragePath($work.'/storage');
foreach(['logs','framework/views','framework/sessions','framework/cache/data'] as $dir)mkdir($work.'/storage/'.$dir,0700,true);
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
App\Shared\Installation\CompositionRuntime::physical();
$host=Illuminate\Support\Facades\DB::connection();
config(['database.connections.receipt_native'=>$s['nativeConnection'],'common-payables.source_instance'=>'qa-stock-ledger-'.$tag,'common-payables.history_enabled'=>false,'common-payables.history_decisions_enabled'=>false]);
$native=Illuminate\Support\Facades\DB::connection('receipt_native');
$f=json_decode(file_get_contents($s['root'].'/fixture.json'),true);$nf=json_decode(file_get_contents($s['root'].'/native-fixture.json'),true);