Skip to content

Commit

Permalink
feat(config): add base swoole config support ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
TIGERB committed Dec 28, 2017
1 parent ef5a901 commit fc78608
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ password = easyphp

[log_path]
path = /runtime/logs/

[swoole]
worker_num = 5
max_request = 10000
log_file = /runtime/logs/easy_swoole.log
1 change: 1 addition & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ app [PHP应用目录]
│ │ └── route.php [模块自定义路由]
│ ├── common.php [公共配置]
│ ├── database.php [数据库配置]
│ ├── swoole.php [swoole配置]
│ └── nosql.php [nosql配置]
docs [接口文档目录]
├── apib [Api Blueprint]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ app [application backend directory]
│ │ └── route.php [module-defined router]
│ ├── common.php [common config]
│ ├── database.php [database config]
│ ├── swoole.php [swoole config]
│ └── nosql.php [nosql config]
docs [api document directory]
├── apib [Api Blueprint]
Expand Down
16 changes: 16 additions & 0 deletions config/swoole.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/********************************************
* Easy PHP *
* *
* A lightweight PHP framework for studying *
* *
* TIERGB *
* <https://github.com/TIGERB> *
* *
********************************************/

use Framework\Helper;

return [
'swoole' => env('swoole')
];
5 changes: 3 additions & 2 deletions framework/handles/ConfigHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ConfigHandle implements Handle
*
* @var array
*/
private $config;
private $config = [];

/**
* 构造函数
Expand Down Expand Up @@ -102,8 +102,9 @@ public function loadConfig(App $app)
$defaultCommon = require($app->rootPath . '/config/common.php');
$defaultNosql = require($app->rootPath . '/config/nosql.php');
$defaultDatabase = require($app->rootPath . '/config/database.php');
$defaultSwoole = require($app->rootPath . '/config/swoole.php');

$this->config = array_merge($defaultCommon, $defaultNosql, $defaultDatabase);
$this->config = array_merge($defaultCommon, $defaultNosql, $defaultDatabase, $defaultSwoole);

/* 加载模块自定义配置 */
$module = $app::$container->getSingle('config')->config['module'];
Expand Down
6 changes: 4 additions & 2 deletions public/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
* Require framework
*/
$easy = require('../framework/swoole.php');
$config = $easy::$container->getSingle('config');
$swooleConfig = $config->config['swoole'];
$easy->runningMode = 'swoole'; // set the app running mode

/**
* 启动swoole http服务
*
* Start the http server
*/
$http = new swoole_http_server('127.0.0.1', 8888);
// set the app running mode
$easy->runningMode = 'swoole';
$http->set($swooleConfig);

/**
* 监听请求
Expand Down

0 comments on commit fc78608

Please sign in to comment.