Last active
February 23, 2020 09:35
-
-
Save Mombuyish/472ef7c5931566d648d856102a0085c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Illuminate\Foundation\Console\ConfigCacheCommand | |
public function handle() | |
{ | |
$this->call('config:clear'); // clear your config cached if it exists. | |
$config = $this->getFreshConfiguration(); // get a new config | |
$configPath = $this->laravel->getCachedConfigPath(); // get cache file path | |
$this->files->put( | |
$configPath, '<?php return '.var_export($config, true).';'.PHP_EOL | |
); // put the cached file. | |
try { | |
require $configPath; // if it generated successful, require the file. | |
} catch (Throwable $e) { // php7 error exception handle. | |
$this->files->delete($configPath); // delete failed file. | |
// throwing a logic exception to tell you, oh, something wents wrong. | |
throw new LogicException('Your configuration files are not serializable.', 0, $e); | |
} | |
// otherwise it's successful. | |
$this->info('Configuration cached successfully!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment