Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor internal configuration loader and remove experimental Phar support #1485

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading