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
  • Loading branch information
caendesilva authored Dec 1, 2023
2 parents a05839c + 9759ad8 commit 66aaf69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ This serves two purposes:

### Security
- in case of vulnerabilities.

### Internal

- Internal: Only inject custom app config location when missing from parent in https://github.com/hydephp/develop/pull/1485
- Internal: Remove experimental Phar support from internal configuration loader in https://github.com/hydephp/develop/pull/1485
25 changes: 1 addition & 24 deletions packages/framework/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 66aaf69

Please sign in to comment.