配置文件 `config.php`:
<?php
return [
'app' => __DIR__.'/../app',
'public' => __DIR__.'/../public',
'base' => __DIR__.'/..'
];
調用處:
$config = require 'config.php'; // 接收返回值
echo $config['app']; // 使用
<?php // config.php
$env = getenv('APP_ENV') ?: 'production';
$common = [ 'debug' => false ];
$specific = [
'development' => ['debug'=>true, 'db'=>'dev_db'],
'production' => ['debug'=>false, 'db'=>'prod_db'],
];
return array_merge($common, $specific[$env]);