Skip to content

Commit

Permalink
Merge pull request #1485 from hydephp/refactor-internal-phar-support
Browse files Browse the repository at this point in the history
Refactor internal configuration loader and remove experimental Phar support hydephp/develop@66aaf69
  • Loading branch information
github-actions committed Dec 1, 2023
1 parent 20276a1 commit 5028631
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/Foundation/Internal/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

namespace Hyde\Foundation\Internal;

use Phar;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Foundation\Bootstrap\LoadConfiguration as BaseLoadConfiguration;

use function getenv;
use function array_merge;
use function dirname;
use function in_array;
use function is_dir;
use function tap;

/** @internal */
Expand All @@ -24,9 +21,7 @@ protected function getConfigurationFiles(Application $app): array
{
return (array) tap(parent::getConfigurationFiles($app), function (array &$files) use ($app): void {
// Inject our custom config file which is stored in `app/config.php`.
$files['app'] = $app->basePath().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'config.php';

$this->providePharSupportIfNeeded($files);
$files['app'] ??= $app->basePath().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'config.php';
});
}

Expand Down Expand Up @@ -61,24 +56,6 @@ private function mergeConfigurationFile(Repository $repository, string $file): v
));
}

/**
* Provide support for running Hyde in a Phar archive.
*
* @experimental
*
* @codeCoverageIgnore
*/
private static function providePharSupportIfNeeded(array &$files): void
{
// If we're running in a Phar and no project config directory exists,
// we need to adjust the path to use the bundled static Phar config file.

/** @var array{app: string} $files */
if (Phar::running() && (! is_dir($files['app']))) {
$files['app'] = dirname(__DIR__, 6).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
}
}

private function loadRuntimeConfiguration(Application $app, Repository $repository): void
{
if ($app->runningInConsole()) {
Expand Down

0 comments on commit 5028631

Please sign in to comment.