diff --git a/library/think/Console.php b/library/think/Console.php
index 991e3a7d..f65fe024 100644
--- a/library/think/Console.php
+++ b/library/think/Console.php
@@ -49,9 +49,11 @@ class Console
"think\\console\\command\\Help",
"think\\console\\command\\Lists",
"think\\console\\command\\Build",
+ "think\\console\\command\\Clear",
"think\\console\\command\\make\\Controller",
"think\\console\\command\\make\\Model",
"think\\console\\command\\optimize\\Autoload",
+ "think\\console\\command\\optimize\\Config",
];
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
diff --git a/library/think/console/command/Clear.php b/library/think/console/command/Clear.php
new file mode 100644
index 00000000..072ce6ec
--- /dev/null
+++ b/library/think/console/command/Clear.php
@@ -0,0 +1,44 @@
+
+// +----------------------------------------------------------------------
+namespace think\console\command;
+
+use think\console\command\Command;
+use think\console\Input;
+use think\console\input\Option;
+use think\console\Output;
+
+class Clear extends Command
+{
+ protected function configure()
+ {
+ // 指令配置
+ $this
+ ->setName('clear')
+ ->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear', null)
+ ->setDescription('Clear runtime file');
+ }
+
+ protected function execute(Input $input, Output $output)
+ {
+ $path = $input->getOption('path') ?: RUNTIME_PATH;
+ $files = scandir($path);
+ if ($files) {
+ foreach ($files as $file) {
+ if ('.' != $file && '..' != $file && is_dir($path . $file)) {
+ array_map('unlink', glob($path . $file . '/*.*'));
+ } elseif (is_file($path . $file)) {
+ unlink($path . $file);
+ }
+ }
+ }
+ $output->writeln("Clear Successed");
+ }
+}
diff --git a/library/think/console/command/optimize/Config.php b/library/think/console/command/optimize/Config.php
new file mode 100644
index 00000000..f3a1b320
--- /dev/null
+++ b/library/think/console/command/optimize/Config.php
@@ -0,0 +1,88 @@
+
+// +----------------------------------------------------------------------
+namespace think\console\command\optimize;
+
+use think\Config;
+use think\console\command\Command;
+use think\console\Input;
+use think\console\input\Option;
+use think\console\Output;
+
+class Config extends Command
+{
+ /** @var Output */
+ protected $output;
+
+ protected function configure()
+ {
+ $this->setName('optimize:config')
+ ->addOption('module', null, Option::VALUE_REQUIRED, 'Build module config cache .')
+ ->setDescription('Build config and common file cache.');
+ }
+
+ protected function execute(Input $input, Output $output)
+ {
+ if ($input->hasOption('module')) {
+ $module = $input->getOption('module') . DS;
+ } else {
+ $module = '';
+ }
+
+ $content = 'buildCacheContent($module);
+
+ if (!is_dir(RUNTIME_PATH . $module)) {
+ @mkdir(RUNTIME_PATH . $module, 0755, true);
+ }
+
+ file_put_contents(RUNTIME_PATH . $module . 'init' . EXT, $content);
+
+ $output->writeln('Succeed!');
+ }
+
+ protected function buildCacheContent($module)
+ {
+ $content = '';
+ $path = realpath(APP_PATH . $module) . DS;
+ // 加载模块配置
+ $config = Config::load(CONF_PATH . $module . 'config' . CONF_EXT);
+
+ // 加载应用状态配置
+ if ($config['app_status']) {
+ $config = Config::load(CONF_PATH . $module . $config['app_status'] . CONF_EXT);
+ }
+
+ // 读取扩展配置文件
+ if ($config['extra_config_list']) {
+ foreach ($config['extra_config_list'] as $name => $file) {
+ $filename = CONF_PATH . $module . $file . CONF_EXT;
+ Config::load($filename, is_string($name) ? $name : pathinfo($filename, PATHINFO_FILENAME));
+ }
+ }
+
+ // 加载别名文件
+ if (is_file(CONF_PATH . $module . 'alias' . EXT)) {
+ $content .= '\think\Loader::addClassMap(' . (var_export(include CONF_PATH . $module . 'alias' . EXT, true)) . ');' . PHP_EOL;
+ }
+
+ // 加载行为扩展文件
+ if (is_file(CONF_PATH . $module . 'tags' . EXT)) {
+ $content .= '\think\Hook::import(' . (var_export(include CONF_PATH . $module . 'tags' . EXT, true)) . ');' . PHP_EOL;
+ }
+
+ // 加载公共文件
+ if (is_file($path . 'common' . EXT)) {
+ $content .= substr(file_get_contents($path . 'common' . EXT), 5) . PHP_EOL;
+ }
+
+ $content .= '\think\Config::set(' . var_export(Config::get(), true) . ');';
+ return $content;
+ }
+}