diff --git a/composer.json b/composer.json index c9d8d71a2c02..ad1ddeff5906 100644 --- a/composer.json +++ b/composer.json @@ -106,7 +106,7 @@ "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.6", "nyholm/psr7": "^1.2", - "orchestra/testbench-core": "^9.1.4", + "orchestra/testbench-core": "^9.1.5", "pda/pheanstalk": "^5.0", "phpstan/phpstan": "^1.4.7", "phpunit/phpunit": "^10.5|^11.0", diff --git a/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php b/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php index 700651913caf..2c608430063f 100644 --- a/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php +++ b/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Bootstrap; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Support\ServiceProvider; class RegisterProviders { @@ -57,7 +58,7 @@ protected function mergeAdditionalProviders(Application $app) $app->make('config')->set( 'app.providers', array_merge( - $app->make('config')->get('app.providers'), + $app->make('config')->get('app.providers') ?? ServiceProvider::defaultProviders()->toArray(), static::$merge, array_values($packageProviders ?? []), ), diff --git a/src/Illuminate/Foundation/Console/ConfigPublishCommand.php b/src/Illuminate/Foundation/Console/ConfigPublishCommand.php index 54ebce46eb94..8e87f064e24d 100644 --- a/src/Illuminate/Foundation/Console/ConfigPublishCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigPublishCommand.php @@ -91,10 +91,14 @@ protected function getBaseConfigurationFiles() { $config = []; + $shouldMergeConfiguration = $this->laravel->shouldMergeFrameworkConfiguration(); + foreach (Finder::create()->files()->name('*.php')->in(__DIR__.'/../../../../config') as $file) { $name = basename($file->getRealPath(), '.php'); - $config[$name] = file_exists($stubPath = (__DIR__.'/../../../../config-stubs/'.$name.'.php')) ? $stubPath : $file->getRealPath(); + $config[$name] = ($shouldMergeConfiguration === true && file_exists($stubPath = (__DIR__.'/../../../../config-stubs/'.$name.'.php'))) + ? $stubPath + : $file->getRealPath(); } return collect($config)->sortKeys()->all(); diff --git a/tests/Integration/Foundation/Console/ConfigPublishCommandTest.php b/tests/Integration/Foundation/Console/ConfigPublishCommandTest.php new file mode 100644 index 000000000000..4fd08ebc6d54 --- /dev/null +++ b/tests/Integration/Foundation/Console/ConfigPublishCommandTest.php @@ -0,0 +1,66 @@ +afterApplicationCreated(function () use ($files) { + $files->ensureDirectoryExists($this->app->basePath('config-stubs')); + }); + + $this->beforeApplicationDestroyed(function () use ($files) { + $files->deleteDirectory($this->app->basePath('config-stubs')); + }); + + parent::setUp(); + } + + #[\Override] + protected function resolveApplicationConfiguration($app) + { + $app->instance(LoadConfiguration::class, new LoadConfiguration()); + + $app->useConfigPath($app->basePath('config-stubs')); + + $app->dontMergeFrameworkConfiguration(); + + parent::resolveApplicationConfiguration($app); + } + + public function testItCanPublishConfigFilesWhenConfiguredWithDontMergeFrameworkConfiguration() + { + $this->artisan('config:publish', ['--all' => true])->assertOk(); + + foreach ([ + 'app', 'auth', 'broadcasting', 'cache', 'cors', + 'database', 'filesystems', 'hashing', 'logging', + 'mail', 'queue', 'services', 'session', 'view', + ] as $file) { + $this->assertFilenameExists("config-stubs/{$file}.php"); + $this->assertStringContainsString( + file_get_contents(package_path(['config', "{$file}.php"])), file_get_contents(config_path("{$file}.php")) + ); + } + + $this->assertSame(config('app.providers'), ServiceProvider::defaultProviders()->toArray()); + } +}