-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
448 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## cache | ||
|
||
```php | ||
use DcrSwoole\Utils\DataRedis; | ||
|
||
|
||
#[Inject] | ||
public DataRedis $redis; | ||
``` | ||
|
||
操作和predis一致 | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
```php | ||
#[RequestMapping(methods: "GET , POST", path:"/test/guzzle")] | ||
public function guzzle($request, $response): string | ||
{ | ||
// $client = di()->get(\GuzzleHttp\Client::class); | ||
$client = $this->guzzleClient; | ||
$result = $client->get('http://127.0.0.1:9501/test1'); | ||
$ret = $result->getBody()->getContents(); | ||
$result->getBody()->close(); | ||
|
||
return 'test '.$ret; | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## install | ||
|
||
### 安装 | ||
``` | ||
composer create-project dcrswoole/framework skeleton | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## request | ||
|
||
```php | ||
#[RequestMapping(methods: "GET , POST", path:"/index/test2")] | ||
#[Middlewares(AuthMiddleware::class, TestMiddleware::class)] | ||
public function test2(): string | ||
{ | ||
di()->get(Request::class)->get(); | ||
di()->get(Request::class)->get('name'); | ||
di()->get(Request::class)->post(); | ||
di()->get(Request::class)->post('name'); | ||
|
||
di()->get(Request::class)->getRawContent(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## response | ||
|
||
```php | ||
#[RequestMapping(methods: "GET , POST", path:"/index/test2")] | ||
#[Middlewares(AuthMiddleware::class, TestMiddleware::class)] | ||
public function test2() | ||
{ | ||
// return 'test 1121'; | ||
return []; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
### 控制器validate | ||
```php | ||
#[RequestMapping(methods: "GET , POST", path:"/test/test4")] | ||
public function test4($request, $response) | ||
{ | ||
$validate = Validation::check($this->request->post ?? [], [ | ||
// add rule | ||
['title', 'min', 40], | ||
['freeTime', 'number'], | ||
]); | ||
|
||
if ($validate->isFail()) { | ||
var_dump($validate->getErrors()); | ||
var_dump($validate->firstError()); | ||
} | ||
|
||
// $postData = $v->all(); // 原始数据 | ||
$safeData = $validate->getSafeData(); // 验证通过的安全数据 | ||
|
||
return $safeData; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|