isDot() || $file->isLink() || str_starts_with($file->getFilename(), '.')) { continue; } $to = $target.'/'.$file->getFilename(); if ($file->isDir()) { $copy($file->getPathname(), $to); } else { copy($file->getPathname(), $to); } } }; foreach (['app', 'config', 'routes', 'database/migrations', 'packages', 'vendor'] as $directory) { $copy($host.'/'.$directory, $clone.'/'.$directory); } mkdir($clone.'/bootstrap/cache', 0700, true); foreach (['app.php', 'providers.php'] as $file) { copy($host.'/bootstrap/'.$file, $clone.'/bootstrap/'.$file); } foreach (['public', 'storage/logs', 'storage/framework/sessions', 'storage/framework/views', 'storage/framework/cache'] as $directory) { mkdir($clone.'/'.$directory, 0700, true); } $copy($bundle, $clone.'/packages/internal-requisitions'); $manifest = json_decode(file_get_contents($bundle.'/manifest.json'), true, 32, JSON_THROW_ON_ERROR); foreach ($manifest['host_overlays'] as $file => $hashes) { if (hash_file('sha256', $clone.'/'.$file) !== $hashes['before_sha256']) { throw new RuntimeException('Clone baseline mismatch.'); } copy($bundle.'/'.$file, $clone.'/'.$file); } file_put_contents($clone.'/config/purchasing-operational.php', 'getenv("IR_HTTP_ENABLED")==="1","target"=>getenv("IR_HTTP_TARGET"),"scopes"=>[getenv("IR_HTTP_SCOPE")]];'); file_put_contents($clone.'/config/purchasing-access.php', '[getenv("IR_HTTP_SCOPE")]];'); return $clone; }