Skip to content

Commit

Permalink
refactor(bin): remove script to the bin
Browse files Browse the repository at this point in the history
  • Loading branch information
TIGERB committed Jun 24, 2018
1 parent edb5125 commit 386d51a
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 61 deletions.
19 changes: 11 additions & 8 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img width="60%" src="logo.png"><p>
<p align="center"><img width="60%" src="http://cdn.tigerb.cn/logo.png"><p>

<p align="center">
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://api.travis-ci.org/TIGERB/easy-php.svg?branch=master" alt="Build Status"></a>
Expand Down Expand Up @@ -110,6 +110,9 @@ frontend [前端源码和资源目录]
├── app.vue [根组件]
├── index.template.html [前端入口文件模板]
├── store.js [vuex store文件]
├── .babelrc [babel配置文件]
├── webpack.config.js [webpack配置文件]
├── yarn.lock [yarn lock文件]
jobs [脚本目录,写业务脚本的地方]
├── demo [模块目录]
│ ├── Demo.php [脚本演示文件]
Expand All @@ -131,12 +134,13 @@ vendor [composer目录]
.git-hooks [git钩子目录]
├── pre-commit [git pre-commit预commit钩子示例文件]
├── commit-msg [git commit-msg示例文件]
.babelrc [babel配置文件]
bin [自动化脚本目录]
├── build [php打包脚本]
├── cli [框架cli模式运行脚本]
├── run [快速开始脚本]
.env.example [环境变量示例文件]
.gitignore [git忽略文件配置]
.travis.yml [持续集成工具travis-ci配置文件]
build [php打包脚本]
cli [框架cli模式运行脚本]
LICENSE [lincese文件]
logo.png [框架logo图片]
composer.json [composer配置文件]
Expand All @@ -145,9 +149,6 @@ package.json [前端依赖配置文件]
phpunit.xml [phpunit配置文件]
README-CN.md [中文版readme文件]
README.md [readme文件]
run [快速开始脚本]
webpack.config.js [webpack配置文件]
yarn.lock [yarn lock文件]
```

Expand Down Expand Up @@ -759,7 +760,7 @@ Command:

快速开始一个demo:
```
php cli --run
cd bin && php cli --run
```
demo如下:

Expand Down Expand Up @@ -917,5 +918,7 @@ cp ./.git-hooks/* ./git/hooks

## 交流群

<img src="http://cdn.tigerb.cn/wechat-blog-qrcode.jpg" width="300px">

<img src="http://cdn.tigerb.cn/qrcode.jpg" width="200px">

19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img width="60%" src="logo.png"><p>
<p align="center"><img width="60%" src="http://cdn.tigerb.cn/logo.png"><p>

<p align="center">
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://api.travis-ci.org/TIGERB/easy-php.svg?branch=master" alt="Build Status"></a>
Expand Down Expand Up @@ -108,6 +108,9 @@ frontend [application frontend source code directory]
├── app.vue [vue root component]
├── index.template.html [frontend entrance template file]
├── store.js [vuex store file]
├── .babelrc [babel config file]
├── webpack.config.js [webpack config file]
├── yarn.lock [yarn lock file]
jobs [Jobs folder, where write you business script]
├── demo [Module folder]
│ ├── Demo.php [Job script example file]
Expand All @@ -129,12 +132,13 @@ vendor [composer vendor directory]
.git-hooks [git hooks directory]
├── pre-commit [git pre-commit example file]
├── commit-msg [git commit-msg example file]
.babelrc [babel config file]
bin [the auto script folder]
├── build [build php code to phar file script]
├── cli [run this framework with the php cli mode]
├── run [quick start script]
.env.example [the environment variables example file]
.gitignore [git ignore config file]
.travis.yml [travis-ci config file]
build [build php code to phar file script]
cli [run this framework with the php cli mode]
LICENSE [lincese file]
logo.png [logo picture]
composer.json [composer file]
Expand All @@ -143,9 +147,6 @@ package.json [dependence file for frontend]
phpunit.xml [phpunit config file]
README-CN.md [readme file chinese]
README.md [readme file]
run [quick start shell script]
webpack.config.js [webpack config file]
yarn.lock [yarn lock file]
```

Expand Down Expand Up @@ -757,7 +758,7 @@ Run:

Quick Start:
```
php cli --run
cd bin && php cli --run
```
demo as follows:

Expand Down Expand Up @@ -910,4 +911,6 @@ project address: [https://github.com/TIGERB/easy-php](https://github.com/TIGERB/

# CONTACT

<img src="http://cdn.tigerb.cn/wechat-blog-qrcode.jpg" width="300px">

<img src="http://cdn.tigerb.cn/qrcode.jpg" width="200px">
12 changes: 6 additions & 6 deletions build → bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ $ext = 'phar';
$time = date('YmdHis', time());
$packageName = "{$packageName}.{$time}.{$ext}";

if (! file_exists(__DIR__ . '/runtime/build/')) {
mkdir(__DIR__ . '/runtime/build/');
if (! file_exists(__DIR__ . '/../runtime/build/')) {
mkdir(__DIR__ . '/../runtime/build/');
}

$phar = new Phar(
__DIR__ . '/runtime/build/' . $packageName,
__DIR__ . '/../runtime/build/' . $packageName,
0,
$packageName
);

$phar->buildFromDirectory(__DIR__ . '/', '/\.php$/');
$phar->buildFromDirectory(__DIR__ . '/', '/\.env$/');
$phar->buildFromDirectory(__DIR__ . '/../', '/\.php$/');
$phar->buildFromDirectory(__DIR__ . '/../', '/\.env$/');
$phar->buildFromDirectory(__DIR__ . '/', '/^cli$/');

$webIndex = "<?php
Expand All @@ -46,4 +46,4 @@ $phar->setStub(
$webIndex
);

echo "Build success in 'runtime/build/{$packageName}' \n";
echo "Build success in '/..runtime/build/{$packageName}' \n";
2 changes: 1 addition & 1 deletion cli → bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ if (isset($input['method'])) {
$_REQUEST['argv'] = $input;

// 载入框架运行文件
require('framework/run.php');
require('../framework/run.php');
4 changes: 2 additions & 2 deletions run → bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
os=$(uname -a | awk 'BEGIN{FS=" "} {print $1}')

# step 1
yarn install
cd ../frontend && yarn install

# step 2
DOMAIN=http://localhost:60000 npm run demo
Expand All @@ -26,4 +26,4 @@ else
fi

# step 4
cd public && php -S "localhost:60000"
cd ../public && php -S "localhost:60000"
54 changes: 36 additions & 18 deletions framework/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ function env($paramName = '')
* @param array $data 数据
* @return mixed
*/
function dump($data = [])
{
ob_start();
var_dump($data);
$output = ob_get_clean();
if (!extension_loaded('xdebug')) {
$output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
$output = '<pre>' . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
if (! function_exists('debug')) {
function dump($data = [])
{
ob_start();
var_dump($data);
$output = ob_get_clean();
if (!extension_loaded('xdebug')) {
$output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
$output = '<pre>' . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
}
echo ($output);
return null;
}
echo ($output);
return null;
}

/**
Expand All @@ -60,12 +62,28 @@ function dump($data = [])
* @param string $fileName log文件名 绝对路径
* @return void
*/
function easy_log($data = [], $fileName = 'debug')
{
$time = date('Y-m-d H:i:s', time());
error_log(
"[{$time}]: " . json_encode($data, JSON_UNESCAPED_UNICODE)."\n",
3,
$fileName . '.log'
);
if (! function_exists('log')) {
function log($data = [], $fileName = 'debug')
{
$time = date('Y-m-d H:i:s', time());
error_log(
"[{$time}]: " . json_encode($data, JSON_UNESCAPED_UNICODE)."\n",
3,
$fileName . '.log'
);
}
}

/**
* debug
*
* @param array $data 数据
* @return void
*/
if (! function_exists('debug')) {
function debug($data = [])
{
header('Content-Type:Application;');
echo json_encode($data, JSON_UNESCAPED_UNICODE);
}
}
16 changes: 5 additions & 11 deletions framework/router/EasyRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class EasyRouter implements Router
*
* @var string
*/
private $executeType = '';
private $executeType = 'controller';

/**
* 请求uri.
Expand Down Expand Up @@ -186,8 +186,8 @@ public function init(App $app)
// 路由策略 the current router strategy
(new $this->routeStrategyMap[$this->routeStrategy])->route($this);

// 判断是app还是job
$this->isAppOrJob($this);
// to do 等待优化
$this->makeClassPath($this);

// 自定义路由判断
if ((new $this->routeStrategyMap['user-defined'])->route($this)) {
Expand Down Expand Up @@ -225,27 +225,21 @@ public function strategyJudge()
}

/**
* 判断是app还是job
* get class path
*
* @return void
*/
public function isAppOrJob()
public function makeClassPath()
{
// 任务类
if ($this->routeStrategy === 'job') {
$className = $this->request->request('job');
$actionName = $this->request->request('action');
$folderName = ucfirst($this->config->config['jobs_folder_name']);
$this->classPath = "{$folderName}\\{$this->moduleName}\\{$className}";
$this->executeType = 'job';
return;
}

// 获取控制器类
$controllerName = ucfirst($this->controllerName);
$folderName = ucfirst($this->config->config['application_folder_name']);
$this->classPath = "{$folderName}\\{$this->moduleName}\\Controllers\\{$controllerName}";
$this->executeType = 'controller';
}

/**
Expand Down
7 changes: 4 additions & 3 deletions framework/router/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ public function route(Router $entrance)
$entrance->actionName = $actionName;

// 获job类
$jobName = ucfirst($jobName);
$appName = ucfirst($entrance->config->config['jobs_folder_name']);
$this->classPath = "{$appName}\\{$moduleName}\\{$jobName}";
$jobName = ucfirst($jobName);
$moduleName = ucfirst($moduleName);
$appName = ucfirst($entrance->config->config['jobs_folder_name']);
$entrance->classPath = "{$appName}\\{$moduleName}\\{$jobName}";
}
}
File renamed without changes.
5 changes: 5 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules

.tmp_staging

yarn-error.log
File renamed without changes.
8 changes: 4 additions & 4 deletions webpack.config.js → frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ var domain = process.env.DOMAIN; // your domain process.env.domain
webpackConfig.entry  = {
app:[
// main
'./frontend/app.js',
'./app.js',
],
};

webpackConfig.output = {
path: path.resolve(__dirname, './public/dist'),
path: path.resolve(__dirname, './../public/dist'),
publicPath: domain+'/dist/',
filename: production? '[name].[hash].js': '[name].js'
};// output
Expand Down Expand Up @@ -71,8 +71,8 @@ webpackConfig.plugins = [
// make index.html
new HtmlWebpackPlugin({
title: 'easy-vue',
filename: path.resolve(__dirname, './public') + '/index.html',
template: './frontend/index.template.html'
filename: path.resolve(__dirname, './../public') + '/index.html',
template: './index.template.html'
}),
// separate css file
new ExtractTextPlugin({
Expand Down
File renamed without changes.
Binary file removed logo.png
Binary file not shown.

0 comments on commit 386d51a

Please sign in to comment.