diff --git a/.gitignore b/.gitignore index 7326d16..d199bf5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ node_modules .tmp_staging yarn-error.log + +clover.cxml diff --git a/README-CN.md b/README-CN.md index f01f8db..44563e7 100644 --- a/README-CN.md +++ b/README-CN.md @@ -4,7 +4,7 @@ Build Status Code Coverage PHP Version -Version +Version Framework Size Framework Phar Size License @@ -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 [脚本演示文件] +│ ├── ... +``` + +任务脚本示例: +``` + + */ +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)] # 如何使用? diff --git a/README.md b/README.md index 5b5f8dc..002c6ba 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Build Status Code Coverage PHP Version -Version +Version Framework Size Framework Phar Size License @@ -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: +``` + + */ +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 cli --build + + [[file: ./build](https://github.com/TIGERB/easy-php/tree/master/build)] # How to use ? diff --git a/cli b/cli index 4ad7a6b..cc27d9f 100644 --- a/cli +++ b/cli @@ -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 \033[33m job \033[0m: The function will running, value format \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 \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]; } diff --git a/framework/App.php b/framework/App.php index d8b3148..e4c44fe 100644 --- a/framework/App.php +++ b/framework/App.php @@ -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; }