Skip to content

Commit

Permalink
feat(run): add a script for run a demo easier ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
TIGERB committed Aug 24, 2017
1 parent da048f8 commit bd05f1e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ vendor
node_modules

.tmp_staging

yarn-error.log
11 changes: 3 additions & 8 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,16 +649,11 @@ require('runtime/build/App.20170505085503.phar');
**网站服务模式:**

快速开始一个demo:
```
步骤 1: yarn install
步骤 2: DOMAIN=http://localhost:666 npm run demo
步骤 3: cd public && sudo php -S localhost:666
访问网站:http://localhost:666/index.html
访问接口:http://localhost:666/Demo/Index/hello
demo如下:
php cli --run
```
demo如下:

<p align="center"><img width="30%" src="demo.gif"><p>

Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ password = easyphp

All output is json in the framework, neithor framework's core error or business logic's output, beacuse I think is friendly.

# Request param check, Support require/length/number check at present. Use as follows:
##### Request param check, Support require/length/number check at present. Use as follows:
```
$request = App::$container->getSingle('request');
$request->check('username', 'require');
Expand Down Expand Up @@ -646,16 +646,12 @@ Run:
**Web Server Mode:**

Quick Start:
```
step 1: yarn install
step 2: DOMAIN=http://localhost:666 npm run demo
step 3: cd public && sudo php -S localhost:666
visit web:http://localhost:666/index.html
visit api:http://localhost:666/Demo/Index/hello
demo as follows:
php cli --run
```
demo as follows:

<p align="center"><img width="30%" src="demo.gif"><p>

**Cli Mode:**
Expand Down
19 changes: 14 additions & 5 deletions cli
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* cli模式
*
* 在php cli模式下运行框架运行框架
*
* 快速开始demo: php cli --run
*/
// php cli --env=<environment> --<method|job>=<value> --<arguments>=<value> ...
// \033[33m env \033[0m: Script run environment
Expand All @@ -36,11 +38,8 @@ $help = function () {
\033[33m arguments \033[0m: Input arguments
\033[33m help \033[0m: Display command list
\033[36m Web Server Usage \033[0m:
step 1: cd public
step 2: php -S <addr>:<port>
For example, php -S 'localhost:666', after that open website 'http://localhost:666/'
\033[36m Quick start demo \033[0m:
php cli --run
\033[32mEasy PHP: A Faster Lightweight Full-Stack PHP Framework. Version 0.7.0\033[0m
Expand All @@ -51,6 +50,13 @@ HELP;
die($string);
};

/**
* 快速开始demo
*/
$demo = function () {
shell_exec('./run');
};

/**
* 获取参数
*/
Expand All @@ -65,6 +71,9 @@ foreach ($argv as $v) {
if ($match[0] === 'help') {
$help();
}
if ($match[0] === 'run') {
$demo();
}
if (isset($match[1])) {
$input[$match[0]] = $match[1];
}
Expand Down
2 changes: 1 addition & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* TIERGB *
* <https://github.com/TIGERB> *
* *
* Version: 0.6.9 *
* Version: 0.7.0 *
********************************************/

// 载入框架运行文件
Expand Down
18 changes: 18 additions & 0 deletions run
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/bash
# Run this framework demo

# step 1
yarn install

# step 2
DOMAIN=http://localhost:60000 npm run demo

# step 3
# mac os
open "http://localhost:60000/index.html"
# linux os
xdg-open "http://localhost:60000/index.html"

# step 4
cd public && php -S localhost:60000

0 comments on commit bd05f1e

Please sign in to comment.