-
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
0 parents
commit 0841373
Showing
180 changed files
with
20,726 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.env | ||
.htaccess | ||
.user.ini | ||
/log/ | ||
runtime | ||
vendor | ||
.idea | ||
Test.php | ||
composer.lock | ||
.phpunit.result.cache | ||
.php-cs-fixer.cache | ||
|
||
|
||
|
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,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Noah Buscher | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,122 @@ | ||
# dcr_swoole框架 - 整合各种包,模仿laravel hyperf 骨架 造的一个简单框架骨架 | ||
|
||
- 集成 laravel orm , restful route, redis, guzzle monolog | ||
- http websocket | ||
- rabbitmq | ||
- container | ||
- event | ||
- middleware | ||
- validate | ||
- monolog | ||
- collection | ||
- carbon | ||
- dotenv | ||
-- 支持路由注解 中间件注解 | ||
|
||
### 分层 (demo未按此方式) | ||
controller -> service ->repository->model | ||
|
||
### http: | ||
|
||
``` | ||
php ./bin/start.php http:start | ||
``` | ||
|
||
### websocket: | ||
|
||
``` | ||
php ./bin/start.php ws:start | ||
``` | ||
|
||
### console: | ||
|
||
``` | ||
php artisan test2 | ||
``` | ||
|
||
### crontab: | ||
|
||
``` | ||
/config/crontab.php enable 改为 true 开启 | ||
``` | ||
|
||
### migrate: | ||
|
||
``` | ||
php migrate.php migrations:generate | ||
php migrate.php migrations:migrate | ||
``` | ||
|
||
### container | ||
|
||
``` | ||
ApplicationContext::getContainer() | ||
或 di() | ||
``` | ||
|
||
## 路由注解和中间件注解 | ||
```php | ||
#[RequestMapping(methods: "GET , POST" , path:"/api/json")] | ||
#[Middlewares(AuthMiddleware::class , TestMiddleware::class)] | ||
public function test() | ||
{ | ||
return 'hello'; | ||
} | ||
``` | ||
|
||
### 更多例子 | ||
|
||
/app/Controller/TestController.php | ||
|
||
### composer依赖组件 | ||
|
||
``` | ||
"doctrine/event-manager": "^1.1", 事件监听 | ||
"doctrine/migrations": "^3.5", migrate | ||
"elasticsearch/elasticsearch": "7.16", es | ||
"firebase/php-jwt": "^6.3", jwt token | ||
"gregwar/captcha": "^1.1", captcha | ||
"guanhui07/database": "^1.0", laravel orm 改 | ||
"guanhui07/dcr-swoole-crontab": "^1.0", crontab | ||
"guanhui07/guzzle": "^1.0", guzzle client | ||
"guanhui07/redis": "^1.0", redis pool | ||
"inhere/console": "^4.1", console command | ||
"inhere/php-validate": "^2.8", validate 验证器 | ||
"intervention/image": "^2.7", image操作 | ||
"middlewares/utils": "^3.0", middleware中间件 | ||
"monolog/monolog": "^2.8", monolog | ||
"mwangithegreat/faker": "^1.9", faker造数据 | ||
"nesbot/carbon": "^2.6", carbon time | ||
"nikic/fast-route": "^1.3", nikic的 resful route | ||
"opis/closure": "^3.6", 闭包序列化 | ||
"php-amqplib/php-amqplib": "dev-master", rabbitmq | ||
"php-di/php-di": "^7.0", 依赖注入 di container | ||
"qiniu/php-sdk": "^7.7", 七牛cdn | ||
"spatie/image": "^2.2", | ||
"symfony/finder": "^5.0", symfony finder | ||
"vlucas/phpdotenv": "^5.4" dotenv读取 | ||
``` | ||
|
||
## 关联 | ||
|
||
参考 hyperf laravel webman 项目 | ||
|
||
https://github.com/guanhui07/dcr fpm以及workerman实现websocket | ||
|
||
https://github1s.com/walkor/webman-framework | ||
|
||
https://github1s.com/hyperf/hyperf | ||
|
||
https://github1s.com/laravel/laravel | ||
|
||
https://github.com/SerendipitySwow/Serendipity-job | ||
|
||
https://github.com/sunsgneayo/annotation 路由注解参考 | ||
|
||
|
||
### todo: | ||
类似`hyperf`实现 Command Crontab AutoController Cacheable 等注解 | ||
|
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console; | ||
|
||
interface BaseInterface | ||
{ | ||
public function handle(); | ||
} |
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console\Command; | ||
|
||
use App\Repository\TestRepository; | ||
use DcrSwoole\Utils\ApplicationContext; | ||
use Inhere\Console\IO\Input; | ||
use Inhere\Console\IO\Output; | ||
use Toolkit\PFlag\FlagsParser; | ||
|
||
/** | ||
* Class Test2 | ||
* @package app\Console\Command | ||
* php artisan test2 | ||
*/ | ||
class Test2 extends \Inhere\Console\Command | ||
{ | ||
protected static string $name = 'test2'; | ||
|
||
protected static string $desc = 'print system ENV information'; | ||
|
||
protected function configFlags(FlagsParser $fs): void | ||
{ | ||
// 绑定选项 | ||
$fs->addOptByRule('update, up', 'bool;update linux command docs to latest'); | ||
$fs->addOptByRule('init, i', 'bool;update linux command docs to latest'); | ||
$fs->addOptByRule('search, s', 'string;input keywords for search'); | ||
|
||
// 绑定参数 | ||
// - 这里没有设置必须 可以不传,获取到就是空string | ||
$fs->addArg('keywords', 'the keywords for search or show docs', 'string'); | ||
} | ||
|
||
protected function execute(Input $input, Output $output) | ||
{ | ||
$keywords = $this->flags->getOpt('search', 23); | ||
var_dump($keywords); | ||
// | ||
// $name = $this->flags->getFirstArg(); | ||
// if ( !$name && !$keywords) { | ||
// // env | grep XXX | ||
// $output->aList($_SERVER, 'ENV Information', ['ucFirst' => false]); | ||
// return; | ||
// } | ||
ApplicationContext::getContainer()->get(TestRepository::class)->fromRepos(); | ||
$output->info("hello world ..."); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console\Command; | ||
|
||
use App\Service\Consumer\BalancePayConsumer; | ||
use Inhere\Console\IO\Input; | ||
use Inhere\Console\IO\Output; | ||
|
||
/** | ||
* 测试使用 rabbitmq 消费者 | ||
* Class Test2Consumer | ||
* @package app\Console\Command | ||
* php artisan test2_consumer | ||
*/ | ||
class Test2Consumer extends \Inhere\Console\Command | ||
{ | ||
protected static string $name = 'test2_consumer'; | ||
|
||
protected static string $desc = 'print system ENV information'; | ||
|
||
protected function execute(Input $input, Output $output) | ||
{ | ||
go(function () { | ||
$producer = new BalancePayConsumer(); | ||
$producer->consumer('balance_pay'); | ||
}); | ||
\Swoole\Event::wait(); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console; | ||
|
||
/** | ||
* 所有的命令类注册 类 | ||
* Class Kernel | ||
*/ | ||
class Kernel | ||
{ | ||
/** | ||
* @todo 通过反射实现#Command注解 | ||
* @see https://github.com/inhere/php-console/wiki | ||
*/ | ||
public static function getCommands(): array | ||
{ | ||
return [ | ||
\App\Console\Command\Test2::class, | ||
\App\Console\Command\Test2Consumer::class, | ||
]; | ||
} | ||
} |
Oops, something went wrong.