Skip to content

Commit

Permalink
docs(README): add job 📝
Browse files Browse the repository at this point in the history
  • Loading branch information
TIGERB committed Aug 29, 2017
1 parent 6aba101 commit c4c7dcf
Showing 5 changed files with 126 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,3 +7,5 @@ node_modules
.tmp_staging

yarn-error.log

clover.cxml
49 changes: 48 additions & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
<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>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://codecov.io/gh/TIGERB/easy-php/branch/master/graph/badge.svg" alt="Code Coverage"></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.7.0-green.svg" alt="Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/version-0.7.1-green.svg" alt="Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/framework-152KB-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>
@@ -141,6 +141,7 @@ package.json [前端依赖配置文件]
phpunit.xml [phpunit配置文件]
README-CN.md [中文版readme文件]
README.md [readme文件]
run [快速开始脚本]
webpack.config.js [webpack配置文件]
yarn.lock [yarn lock文件]
@@ -571,6 +572,49 @@ App::$container->getSingle('mongodb');

[[file: framework/nosql/*](https://github.com/TIGERB/easy-php/tree/master/framework/nosql)]

## Job Support

我们可以在jobs目录下直接编写我们的任务脚本,如下

```
jobs [脚本目录,写业务脚本的地方]
├── demo [模块目录]
│ ├── Demo.php [脚本演示文件]
│ ├── ...
```

任务脚本示例:
```
<?php
namespace Jobs\Demo;
/**
* Demo Jobs
*
* @author TIERGB <https://github.com/TIGERB>
*/
class Demo
{
/**
* job
*
* @example php cli --jobs=demo.demo.test
*/
public function test()
{
echo 'Hello Easy PHP Jobs';
}
}
```

最后直接运行下面的命令即可:
```
php cli --job=demo.demo.test
```

[[file: jobs/*](https://github.com/TIGERB/easy-php/tree/feature/router/jobs)]

## 接口文档生成和接口模拟模块

通常我们写完一个接口后,接口文档是一个问题,我们这里使用Api Blueprint协议完成对接口文档的书写和mock(可用),同时我们配合使用Swagger通过接口文档实现对接口的实时访问(目前未实现)。
@@ -658,6 +702,9 @@ runtime/build/App.20170505085503.phar
require('runtime/build/App.20170505085503.phar');
```

Command:
> php cli --build
[[file: ./build](https://github.com/TIGERB/easy-php/tree/master/build)]

# 如何使用?
65 changes: 57 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
<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>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://codecov.io/gh/TIGERB/easy-php/branch/master/graph/badge.svg" alt="Code Coverage"></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.7.0-green.svg" alt="Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/version-0.7.1-green.svg" alt="Version"></a>
<a href="https://github.com/TIGERB/easy-php/releases"><img src="https://img.shields.io/badge/framework-152KB-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>
@@ -140,6 +140,7 @@ 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]
@@ -232,13 +233,13 @@ $request->check('code', 'number');

```
├── router [datebase object relation map class directory]
├── RouterInterface.php [router strategy interface]
├── General.php [general strategy class]
├── Pathinfo.php [pathinfo strategy class]
├── Userdefined.php [userdefined strategy class]
├── Micromonomer.php [micromonomer strategy class]
├── Job.php [job strategy class]
└── EasyRouter.php [router strategy entrance class]
├── RouterInterface.php [router strategy interface]
├── General.php [general strategy class]
├── Pathinfo.php [pathinfo strategy class]
├── Userdefined.php [userdefined strategy class]
├── Micromonomer.php [micromonomer strategy class]
├── Job.php [job strategy class]
└── EasyRouter.php [router strategy entrance class]
```

Execute the target controller's function by the router parse the url information.Is composed of four types of:
@@ -570,6 +571,49 @@ App::$container->getSingle('mongodb');

[[file: framework/nosql/*](https://github.com/TIGERB/easy-php/tree/master/framework/nosql)]

## Job Support

You can do some job in the jobs folder directly as follows:

```
jobs [Jobs folder, where write you business script]
├── demo [Module folder]
│ ├── Demo.php [Job script example file]
│ ├── ...
```

Job demo file:
```
<?php
namespace Jobs\Demo;
/**
* Demo Jobs
*
* @author TIERGB <https://github.com/TIGERB>
*/
class Demo
{
/**
* job
*
* @example php cli --jobs=demo.demo.test
*/
public function test()
{
echo 'Hello Easy PHP Jobs';
}
}
```

So, just run the command:
```
php cli --job=demo.demo.test
```

[[file: jobs/*](https://github.com/TIGERB/easy-php/tree/feature/router/jobs)]

## Api Docs

Usually after we write an api, the api documentation is a problem, we use the Api Blueprint protocol to write the api document and mock. At the same time, we can request the api real-timely by used Swagger (unavailable).
@@ -653,8 +697,13 @@ runtime/build/App.20170505085503.phar
<?php
// require the phar file in index.php file
require('runtime/build/App.20170505085503.phar');
```

Command:
> php cli --build

[[file: ./build](https://github.com/TIGERB/easy-php/tree/master/build)]

# How to use ?
18 changes: 18 additions & 0 deletions cli
Original file line number Diff line number Diff line change
@@ -32,14 +32,19 @@ $help = function () {
php cli --job=demo.demo.test --username=test

\033[36m Params mean \033[0m:
\033[33m run \033[0m: Quick start this framework
\033[33m method \033[0m: The function will running, value format <module.controller.action>
\033[33m job \033[0m: The function will running, value format <module.job.action>
\033[33m arguments \033[0m: Input arguments
\033[33m build \033[0m: Build this app file to the phar file
\033[33m help \033[0m: Display command list

\033[36m Quick start demo \033[0m:
php cli --run

\033[36m Build framework to phar file \033[0m:
php cli --build

\033[32mEasy PHP: A Faster Lightweight Full-Stack PHP Framework. Version 0.7.1\033[0m

\033[32mAuthor : TIGERB <https://github.com/TIGERB>\033[0m
@@ -54,6 +59,16 @@ HELP;
*/
$demo = function () {
shell_exec('./run');
die;
};

/**
* 打包
*/
$build = function () {
shell_exec('php build');
echo "SUCCESS";
die;
};

/**
@@ -73,6 +88,9 @@ foreach ($argv as $v) {
if ($match[0] === 'run') {
$demo();
}
if ($match[0] === 'build') {
$build();
}
if (isset($match[1])) {
$input[$match[0]] = $match[1];
}
2 changes: 1 addition & 1 deletion framework/App.php
Original file line number Diff line number Diff line change
@@ -223,7 +223,7 @@ public function callSelf($method = '', $uri = '', $argus = array())
$router->controllerName = $requestUri[1];
$router->actionName = $requestUri[2];
$router->routeStrategy = 'micromonomer';
$router->route();
$router->init($this);
return $this->responseData;
}

0 comments on commit c4c7dcf

Please sign in to comment.