for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Northwoods\Config\Loader;
class PhpLoader implements LoaderInterface
{
public static function isSupported(): bool
return true;
}
public function load(string $path): array
if (is_file("$path.php")) {
$path = $path;
return require "$path.php";
return [];
public function unload(string $path, array $data)
if ( is_file("{$path}.php") && !copy("{$path}.php", "{$path}.backup.php") ) {
throw LoaderException::backupFail(static::class);
$filename = basename($path);
file_put_contents("{$path}.php" , "<?php " . PHP_EOL . " return " . \Northwoods\Config\varexport($data[$filename], true) . ';' . PHP_EOL);