[TOC]
# 1.5 修改配置
## 1.3.1 修改`$configure`變量
這就是實例化`\X\Application`(在`/Public/index.php`中)時,傳遞的一個參數。
### 1.3.1.1 一個標準的示例
```php
$configure = [
"SysDir" => SysDir,
"Path" => [
"Route" => "Var/Route/",
"Application" => "App/",
"Template" => "Var/Template/",
"Cache" => "Var/Cache/"
],
"View" => [
"Start" => "{{",
"End" => "}}",
"ExtName" => ".tpl",
"Template" => "default",
"Cache" => false
],
"Database"=> [
'connection_string' => 'mysql:host=localhost;dbname=xphp;charset=utf8', //DSN
'driver_options' => array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), //PDO Option
'username' => 'root', //用戶名 username
'password' => '', //密碼 password
'logging' => true, //開啟Query日志 Enable Query Log
'caching' => true, //開啟緩存 Enalble Cache
'caching_auto_clear'=> true //自動清理緩存 Auto Clear Cache
],
"Route" => [
"Base" => ""
],
"Version" => X,
"Debug" => true
];
```
### 1.3.1.2 詳解
我想大家猜也猜得出來到底應該怎么改吧。
## 1.3.2 修改`Register.php`
### 1.3.2.1 這是什么
這是將XPHP內部組件注冊入容器中的腳本,您如果覺得XPHP的某一個組件不好用(例如Log),您可以輕松的自己封裝一個,然后在此處修改默認注冊即可。
### 1.3.2.2 標準示例
如果您改錯了,可以使用這一份:
```php
<?php
/**
* XPHP Configure File
*
* You can add your providers here.
*
*/
return function ($App) {
$App->container->add('Core.Error', '\Whoops\Run')->
withMethodCall('pushHandler', ['Core.Error.Handler'])->
withMethodCall('pushHandler', [new \League\Container\Argument\RawArgument(function(
$exception, $inspector, $run
) use ($App){
$App->event->emit('Core.Error', $exception, $inspector, $run);
})])->
withMethodCall('allowQuit', [new \League\Container\Argument\RawArgument(false)])->
withMethodCall('register', []);
$App->addBatch([
['Core.Error.Handler', '\Whoops\Handler\PrettyPageHandler'],
['Core.Route', '\X\Route'],
['Core.Model.Database', '\X\Database\Idiorm']
]);
$App->shareBatch([
['Core.Log', '\X\Log'],
['Core.View', '\X\ViewLightnCandy'],
]);
};
```
## 1.3.3 修改`Config.php`
在此文件中,您不僅可以修改系統類的注冊,也可以對于`$configure`變量進行修改。
### 1.3.3.1 修改注冊
與修改`Register.php`完全一致。
### 1.3.3.2 修改`$configure`
使用
```php
$App->config
```
即可訪問到`$configure`變量,您可以隨意修改。