Skip to content

Commit

Permalink
Merge pull request #1076 from hydephp/experimental-phar-support
Browse files Browse the repository at this point in the history
Update LoadConfiguration to support static Phar config
  • Loading branch information
caendesilva committed Feb 20, 2023
2 parents 7d250d4 + ddaf587 commit d2f71da
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/framework/src/Foundation/Internal/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ protected function getConfigurationFiles(Application $app): array
return 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);
});
}

Expand Down Expand Up @@ -48,4 +50,20 @@ private function mergeConfigurationFile(RepositoryContract $repository, string $
(array) $repository->get($file, [])
));
}

/**
* 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.

if (\Phar::running() && (! is_dir($files['app']))) {
$files['app'] = dirname(__DIR__, 6).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
}
}
}

0 comments on commit d2f71da

Please sign in to comment.