forked from zendframework/zend-expressive-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Per conversation on zendframework#54, we want to make production settings the default, which means enabling the configuration cache. However, we also need to make it easy for developers to clear the configuration cache. This patch adds a script, `bin/clear-config-cache.php`, which can be used to remove the configured configuration cache file, if defined. It is aliased in `composer.json` as `clear-config-cache`, allowing usage as `composer clear-config-cache`.
- Loading branch information
1 parent
d973761
commit 4440dfd
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* Script for clearing the configuration cache. | ||
* | ||
* Can also be invoked as `composer clear-config-cache`. | ||
* | ||
* @see https://github.com/zendframework/zend-expressive-skeleton for the canonical source repository | ||
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license https://github.com/zendframework/zend-expressive-skeleton/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
chdir(__DIR__ . '/../'); | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$config = include 'config/config.php'; | ||
|
||
if (! isset($config['config_cache_path'])) { | ||
echo "No configuration cache path found" . PHP_EOL; | ||
exit(0); | ||
} | ||
|
||
if (! file_exists($config['config_cache_path'])) { | ||
printf( | ||
"Configured config cache file '%s' not found%s", | ||
$config['config_cache_path'], | ||
PHP_EOL | ||
); | ||
exit(0); | ||
} | ||
|
||
if (false === unlink($config['config_cache_path'])) { | ||
printf( | ||
"Error removing config cache file '%s'%s", | ||
$config['config_cache_path'], | ||
PHP_EOL | ||
); | ||
exit(1); | ||
} | ||
|
||
printf( | ||
"Removed configured config cache file '%s'%s", | ||
$config['config_cache_path'], | ||
PHP_EOL | ||
); | ||
exit(0); |
This file contains 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