Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
TIGERB committed May 14, 2017
2 parents 5eb4f86 + e418f8e commit 4be26a0
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 141 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vendor

.env.prod
.env

node_modules
14 changes: 10 additions & 4 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p align="center">
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/build-passing-brightgreen.svg" alt="Build Status"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/php-5.4%2B-blue.svg" alt="PHP Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/version-0.6.6-green.svg" alt="Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/version-0.6.7-green.svg" alt="Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/framework-148KB-orange.svg" alt="Framework Size"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/framework--phar-76KB-red.svg" alt="Framework Phar Size"></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/cocoapods/l/AFNetworking.svg" alt="License"></a>
Expand Down Expand Up @@ -607,6 +607,7 @@ require('runtime/build/App.20170505085503.phar');
执行:

- composer install
- cp .env.example .env
- chmod -R 777 runtime

**网站服务模式:**
Expand Down Expand Up @@ -655,9 +656,6 @@ cp ./.git-hooks/* ./git/hooks

# TODO

- 懒加载优化框架加载流程
- 性能测试和优化
- 变更Helper助手类的成员方法为框架函数,简化使用提高生产效率
- 提供更友善的开发api帮助
- 模块支持数据库nosql自定义配置
- 支持mysql主从配置
Expand All @@ -666,3 +664,11 @@ cp ./.git-hooks/* ./git/hooks
- 想办法解决上线部署是配置文件问题
- 基于phar文件和git webhook自动化打包部署
- ...

# DONE

- v0.6.7(2017/05/14)
- 修复未设置默认时区
- 懒加载优化框架加载流程
- 变更Helper助手类的成员方法为框架函数,简化使用提高生产效率
- 性能测试和优化
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p align="center">
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/build-passing-brightgreen.svg" alt="Build Status"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/php-5.4%2B-blue.svg" alt="PHP Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/version-0.6.6-green.svg" alt="Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/version-0.6.7-green.svg" alt="Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/framework-148KB-orange.svg" alt="Framework Size"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/framework--phar-76KB-red.svg" alt="Framework Phar Size"></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/cocoapods/l/AFNetworking.svg" alt="License"></a>
Expand Down Expand Up @@ -604,6 +604,7 @@ require('runtime/build/App.20170505085503.phar');
Run:

- composer install
- cp .env.example .env
- chmod -R 777 runtime

**Web Server Mode:**
Expand Down Expand Up @@ -648,9 +649,6 @@ project address: [https://github.com/TIGERB/easy-php](https://github.com/TIGERB/

# TODO

- The performance test and optimize
- Use the lazy load thought to optimize the framework
- Change Helper's method to the framework's function
- Provide much friendly help for user
- Module's config support module-defined mysql and nosql configuration
- Support master-salve mysql configuration
Expand All @@ -659,3 +657,12 @@ project address: [https://github.com/TIGERB/easy-php](https://github.com/TIGERB/
- Resolve config problem when publish our project
- implement auto deploy by used phar and git webhook
- ...


# DONE

- v0.6.7(2017/05/14)
- fix not set default time zone
- The performance test and optimize
- Use the lazy load thought to optimize the framework
- Change Helper's method to the framework's function
1 change: 0 additions & 1 deletion app/demo/controllers/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace App\Demo\Controllers;

use Framework\App;
use Framework\Helper;
use Framework\Loger;

/**
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "TIGERB/easy-php",
"description": "A lightweight PHP framework for studying",
"version":"0.3.6",
"type": "framework",
"version":"0.6.7",
"type": "framework, easy-php, php framework",
"authors": [
{
"name": "tigerb",
Expand Down
14 changes: 6 additions & 8 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
* *
********************************************/

use Framework\Helper;

return [
/* 默认配置 */
'database' => [
'dbtype' => Helper::env('database')['dbtype'],
'dbprefix' => Helper::env('database')['dbprefix'],
'dbname' => Helper::env('database')['dbname'],
'dbhost' => Helper::env('database')['dbhost'],
'username' => Helper::env('database')['username'],
'password' => Helper::env('database')['password']
'dbtype' => env('database')['dbtype'],
'dbprefix' => env('database')['dbprefix'],
'dbname' => env('database')['dbname'],
'dbhost' => env('database')['dbhost'],
'username' => env('database')['username'],
'password' => env('database')['password']
]
];
26 changes: 12 additions & 14 deletions config/nosql.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,42 @@
* nosql相关配置
*/

use Framework\Helper;

return [
// 需要提供支持的nosql种类
// 参数示例:redis,memcached,mongoDB
'nosql' => Helper::env('nosql')['support'],
'nosql' => env('nosql')['support'],

// redis
'redis' => [
// 默认host
'host' => Helper::env('redis')['host'],
'host' => env('redis')['host'],
// 默认端口
'port' => Helper::env('redis')['port'],
'port' => env('redis')['port'],
// 密码
'password' => Helper::env('redis')['password'],
'password' => env('redis')['password'],
],

// memcached
'memcached' => [
// 默认host
'host' => Helper::env('memcached')['host'],
'host' => env('memcached')['host'],
// 默认端口
'port' => Helper::env('memcached')['port'],
'port' => env('memcached')['port'],
// 密码
'password' => Helper::env('memcached')['password'],
'password' => env('memcached')['password'],
],

// mongoDB
'mongoDB' => [
// 默认host
'host' => Helper::env('mongoDB')['host'],
'host' => env('mongoDB')['host'],
// 默认端口
'port' => Helper::env('mongoDB')['port'],
'port' => env('mongoDB')['port'],
// 数据库名称
'database' => Helper::env('mongoDB')['database'],
'database' => env('mongoDB')['database'],
// 用户名
'username' => Helper::env('mongoDB')['username'],
'username' => env('mongoDB')['username'],
// 密码
'password' => Helper::env('mongoDB')['password'],
'password' => env('mongoDB')['password'],
]
];
84 changes: 0 additions & 84 deletions framework/Helper.php

This file was deleted.

9 changes: 6 additions & 3 deletions framework/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function get($value = '', $default = '', $checkEmpty = true)
if (empty($this->getParams[$value]) && $checkEmpty) {
return $default;
}
return $this->getParams[$value];
return htmlspecialchars($this->getParams[$value]);
}

/**
Expand All @@ -229,7 +229,7 @@ public function post($value = '', $default = '', $checkEmpty = true)
if (empty($this->getParams[$value]) && $checkEmpty) {
return $default;
}
return $this->postParams[$value];
return htmlspecialchars($this->postParams[$value]);
}

/**
Expand All @@ -248,7 +248,7 @@ public function request($value = '', $default = '', $checkEmpty = true)
if (empty($this->getParams[$value]) && $checkEmpty) {
return $default;
}
return $this->requestParams[$value];
return htmlspecialchars($this->requestParams[$value]);
}

/**
Expand All @@ -259,6 +259,9 @@ public function request($value = '', $default = '', $checkEmpty = true)
public function all()
{
$res = array_merge($this->postParams, $this->getParams);
foreach ($res as &$v) {
$v = htmlspecialchars($v);
}
return $res;
}

Expand Down
9 changes: 7 additions & 2 deletions framework/handles/ConfigHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,16 @@ public function __set($name = '', $value = '')
*/
public function register(App $app)
{
// load helper function file
require($app->rootPath . '/framework/helper.php');

$this->app = $app;
$app::$container->setSingle('config', $this);
$this->loadConfig($app);
// 加载时区
date_default_timezone_set($this->config['default_timezone']);

// 设置时区
// define time zone
date_default_timezone_set($this->config['default_timezone']);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions framework/handles/LogHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Framework\App;
use Framework\Handles\Handle;
use Framework\Helper;
use Framework\Exceptions\CoreHttpException;

/**
Expand Down Expand Up @@ -64,7 +63,7 @@ public function __construct()
*
* check log path env config
*/
$this->logPath = Helper::env('log_path');
$this->logPath = env('log_path');
if (empty($this->logPath) || ! isset($this->logPath['path'])) {
throw new CoreHttpException(400, 'log path is not defined');
}
Expand All @@ -90,7 +89,7 @@ public function __construct()
*/
public function write($data = [])
{
Helper::log(
easy_log(
$data,
$this->logPath . $this->logFileName
);
Expand Down
15 changes: 12 additions & 3 deletions framework/handles/NosqlHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
/**
* nosql处理机制
*
* nosql handle
*
* @author TIERGB <https://github.com/TIGERB>
*/
class NosqlHandle implements Handle
{
/**
* 构造函数
*
* construct
*/
public function __construct()
{
Expand All @@ -32,9 +36,11 @@ public function __construct()


/**
* 注册配置文件处理机制
* 注册nosql处理机制
*
* register nosql handle
*
* @param App $app 框架实例
* @param App $app 框架实例 This framework instance
* @return void
*/
public function register(App $app)
Expand All @@ -46,7 +52,10 @@ public function register(App $app)
$config = explode(',', $config->config['nosql']);
foreach ($config as $v) {
$className = 'Framework\Nosql\\' . ucfirst($v);
new $className();
App::$container->setSingle($v, function () use ($className) {
// 懒加载 lazy load
return $className::init();
});
}
}
}
Loading

0 comments on commit 4be26a0

Please sign in to comment.