Skip to content

Commit

Permalink
Check if configuration cache is valid after saving
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh authored Jul 2, 2018
1 parent 1ce5f49 commit b463015
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Illuminate/Foundation/Console/ConfigCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Foundation\Console;

use LogicException;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract;
Expand Down Expand Up @@ -52,11 +53,19 @@ public function handle()
$this->call('config:clear');

$config = $this->getFreshConfiguration();
$configPath = $this->laravel->getCachedConfigPath();

$this->files->put(
$this->laravel->getCachedConfigPath(), '<?php return '.var_export($config, true).';'.PHP_EOL
$configPath, '<?php return '.var_export($config, true).';'.PHP_EOL
);

try {
require $configPath;
} catch (\Throwable $e) {
$this->files->delete($configPath);
throw new LogicException('Unable to cache Laravel configuration.', 0, $e);
}

$this->info('Configuration cached successfully!');
}

Expand Down

0 comments on commit b463015

Please sign in to comment.