swoft-cloud / swoft Goto Github PK
View Code? Open in Web Editor NEW🚀 PHP Microservice Full Coroutine Framework
Home Page: https://swoft.org
License: Apache License 2.0
🚀 PHP Microservice Full Coroutine Framework
Home Page: https://swoft.org
License: Apache License 2.0
Swoole\Coroutine\Redis 不可以加入默认前缀,严重影响编码体验。
例如:
$redis->setOption(Redis::OPT_PREFIX, 'myAppName:');
这种写法,完全不支持。
大多数必须使用 use,类似:
use Swoft\App;
App::trace("this is child trace" . Coroutine::id());
而不能直接的:App::trace("this is child trace" . Coroutine::id()); 不需要进行 use 引用。
项目需要使用到PostgreSQL不知道是否可以有办法连接?或者是连接池?谢谢
类似laravel框架Eloquent的SoftDeletes
数据表带时间戳字段deleted_at
顺便是否可支持
数据新增自动填充created_at
数据更新自动更新updated_at
我看文档里面的RPC列子,服务提供者 和服务消费者是在通一个项目下进行的调用。
实际场景是服务提供者和服务消费者分别在各自的项目里面
我想问的是
服务消费者和服务提供者的项目都用你们的swoft框架
服务消费者的项目里面要如何配置信息
open(/home/vagrant/Code/swoft/runtime/logs/swoole.log) failed. Error: No such file or directory[2]
运行后随便访问一个url,则框架会自动生成文件,同时生成目录
runtime/logs/notice.log
退出命令行后第二次运行,由于第一次生成的文件/目录,第二次可以正常运行不报错,并可以正常写入swoole.log 文件
其实我觉得框架应该默认带runtime/logs 这个目录,方便写入日志,而不用运行时创建
使用最新1.0的demo代码 想在demoController 直接调用Service
/**
* @Reference("user")
*
* @var \App\Lib\DemoInterface
*/
private $demoService;
报错
[Semantical Error] The annotation "@reference" in property App\Controllers\DemoController::$demoService was never imported. Did you maybe forget to add a "use" statement for this annotation
Document can use this: https://github.com/QingWei-Li/docsify ----> https://docsify.js.org/
and this: https://github.com/egoist/docute ---------> https://docute.js.org/
.php 配置对于集群来说限制比较大,它不能很好的做自动化写入、更改处理。
看了swoft的文档发现没有直接的方法直接输出网页模板是吗? 是能使用response->setResponseContent是吗?
syntax error, unexpected '?'
在控制器一节中 注入的依赖默认是单列的。
应为 单例
开发时更改了代码都需要重启,是否提供开发模式不用每次都重启服务
一般建表都会带上特定的前缀,比如表名为lj_users,现生成实体命名为LjUsers,实际希望为Users,希望可以加个命令参数配置去除前缀
[2017-11-17 08:24:35 *16581.0] ERROR zm_deactivate_swoole (ERROR 503): Fatal error: Uncaught InvalidArgumentException: the name of bean 不存在, name=lineFormate in /home/vagrant/Code/swoft/vendor/swoft/framework/src/Bean/Container.php:70
Stack trace:
#0 /home/vagrant/Code/swoft/vendor/swoft/framework/src/Bean/Container.php(277): Swoft\Bean\Container->get('lineFormate')
#1 /home/vagrant/Code/swoft/vendor/swoft/framework/src/Bean/Container.php(186): Swoft\Bean\Container->injectProperties(Object(Swoft\Log\FileHandler), Array, Array)
#2 /hom
运行代码:
$result1 = Mobiles::query()->select('*')->where('mobile', '1571155')->limit(1)->getDefer();
$result = $this->redis->set('test1', 1);
var_dump($result);
var_dump($result1->getResult());
执行测试:
ab -n 10 -c 10 http://192.168.1.199:8098/mok/test
抛出警告:
PHP Warning: Swoole\Coroutine\MySQL::query(): mysql client has already been bound to another coroutine. in /dir/project/vendor/swoft/framework/src/Db/Mysql/MysqlConnect.php on line 55
我把homestead 的 项目目录 和 本机的 项目目录进行同步
我在本机进行修改项目目录里的文件,自动重载不能正常进行,但是ssh到homestead中修改可以正常重载。
本地开发时,有跨域情况出现,ajax会预发options请求,但是swoft不支持
请问这个内存碎片问题是怎么解决的
mac 系统不支持设置进程名称,希望设置进程名的时候做个兼容判断
加我QQ:89225123,谢谢
Q | A |
---|---|
Bug report? | yes |
Feature request? | yes/no |
Swoft version | beta |
Swoole version | 2.1.0 |
PHP version | 7.1.4 |
Details
只配置主数据库,可以通过命令行生成实体,但是直接通过sql语句查询,无法查询
error.log
2018/03/05 06:07:39 [error] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] mysql执行出错,connectError= error=
2018/03/05 06:07:39 [warning] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] Key 2-select * from sl_book-transaction-swoft does not exist
2018/03/05 06:07:39 [warning] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] Key contextConnects does not exist
2018/03/05 06:07:39 [warning] [swoft] [logid:5a9cdeab2824c] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] Key contextConnects does not exist
notice.log
2018/03/05 06:07:37 [notice] [swoft] [logid:5a9cdea99d433] [spanid:0] [0.74(ms)] [8(MB)] [process-cronTimer] [] profile[] counting[]
2018/03/05 06:07:37 [notice] [swoft] [logid:5a9cdea9a4fa8] [spanid:0] [0.79(ms)] [8(MB)] [process-cronExec] [] profile[] counting[]
2018/03/05 06:07:39 [debug] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] sql execute sqlId=d41d8cd98f00b204e9800998ecf8427e, sql=
2018/03/05 06:07:39 [debug] [swoft] [logid:5a9cdeab04f66] [spanid:0] trace[AopHandler.php:42,Swoft\Proxy\Handler\AopHandler->invoke] SQL语句执行结果(defer) sqlId=mysql result=false
2018/03/05 06:07:39 [notice] [swoft] [logid:5a9cdeab04f66] [spanid:0] [18.17(ms)] [8(MB)] [http://localhost:9501/] [] profile[] counting[]
2018/03/05 06:07:39 [notice] [swoft] [logid:5a9cdeab2824c] [spanid:0] [0.34(ms)] [8(MB)] [http://localhost:9501/favicon.ico] [] profile[] counting[]
Provide minimal script to reproduce the issue
$sql = "select * from sl_book";
$em = EntityManager::create();
$query = $em->createQuery($sql);
$res = $query->execute()->getResult();
$em->close();
官方网站文档连接全部错误无法打开
如 name="age" , min=18
如果参数 age = 15 , 建议提示 age is too small 而不是 15 is too small
PHP Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /apps/webroot/production/bsf/vendor/swoft/framework/src/Console/CommandParser.php on line 39
比如访问友商接口基本先登录,然后访问,能自动管理cookie就好了
1.0代码 demo 跑起来 找不到user pool
都哪些配置项会影响到 ?
rpcController.php
demo
service.php
<?php
return [
'consul' => [
'address' => '',
'port' => 8500,
'register' => [
'id' => '',
'name' => '',
'tags' => [],
'enableTagOverride' => false,
'service' => [
'address' => 'localhost',
'port' => '8099',
],
'check' => [
'id' => '',
'name' => '',
'tcp' => 'localhost:8099',
'interval' => 10,
'timeout' => 1,
],
],
'discovery' => [
'name' => 'user',
'dc' => 'dc',
'near' => '',
'tag' => '',
'passing' => true,
],
],
];
app.php
<?php
return [
'version' => '1.0',
'autoInitBean' => true,
'bootScan' => [
'App\Commands',
'App\Boot',
],
'beanScan' => [
'App\Controllers',
'App\Tasks',
'App\Services',
'App\Exception',
'App\Listener',
],
'env' => 'Base',
'cache' => require __DIR__ . DS . 'cache.php',
'service' => require __DIR__ . DS . 'service.php',
'provider' => require __DIR__ . DS . 'provider.php',
];
Please remove yii from:
Swoft\Helper\ArrayHelper:569
thanks for swoft
@stelin Hi, 你好。关于swoft有没有统一的代码风格,比如psr2 or Zend?,如果需要修改部分代码,以统一风格,我可以贡献一点。
psr2的风格怎么样呢?
首先,对这个框架,我是非常肯定和认可的。确实也是很NB的一个框架。
当我去翻框架的时候发现,好多单词写错了,phpstorm有N多错单词的提示。举例:
current写成了currrent,switch写成了swith.
default 为NULL 并没有验证参数是否存在 , 而是默认为NULL
#问题描述
环境:macos
php版本:
PHP 7.0.0 (cli) (built: Dec 2 2015 13:35:31) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
swoft版本:1.0
描述:
1.使用composer create-project swoft/swoft swoft dev-master
初始化项目
2.使用php swoft start
开始项目会出现报错,不晓得是不是我php版本低的原因,报错信息如下:
`Fatal error: Cannot use Swoole\Coroutine\Redis as Redis because the name is already in use in /Users/fatjiong/Sites/swoft/vendor/swoft/redis/src/RedisConnect.php on line 9`
解决:
经查看是"./vendor/swoft/redis/src/RedisConnect.php"类内的第九行:use Swoole\Coroutine\Redis;
引用命名空间重复了,我做了下修改,修改成以下这种:
line 9:`use Swoole\Coroutine\Redis as newRedis;`
line 37:`$redis = new newRedis();`
用as取别名避免命名空间重复,不知道这样子处理是否可行?
PS:跑docker安装的时候没有发现该问题。
重新执行`php swoft start`,框架已经可以正常执行:
`
Information Panel
******************************************************************
* http | Host: 0.0.0.0, port: 8888, Model: 3, type: 1, Worker: 1
* tcp | Enable: 1, host: 0.0.0.0, port: 8099, type: 1, Worker: 1
******************************************************************
`
可以看到redis还是协程的,为何mysql/http切换成了同步阻塞呢?
嗨, 在我的php7.0环境下试运行,发现请求响应时终端会输出
PHP Fatal error: Uncaught TypeError: Return value of Swoft\Web\Response::send() must be an instance of Swoft\Web\void, none returned in /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Web/Response.php:179
Stack trace:
#0 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Web/Application.php(69): Swoft\Web\Response->send()
#1 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Server/HttpServer.php(66): Swoft\Web\Application->doRequest(Object(swoole_http_request), Object(swoole_http_response))
#2 [internal function]: Swoft\Server\HttpServer->onRequest(Object(swoole_http_request), Object(swoole_http_response))
#3 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Server/HttpServer.php(55): swoole_http_server->start()
#4 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Console/Command/ServerController.php(125): Swoft\Server\HttpServer->start()
#5 /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Helper/PhpHelper.php(50): Swoft\Console\Command\ServerController->startComma in /home/quzhi/Code/zpjinfu-service/vendor/swoft/framework/src/Web/Response.php on line 179
我查看后发现 send方法定义了一个 void类型返回值, 但是php7.0貌似并不支持返回void类型
难道这个项目一定要用php7.1+吗?
PHP Warning: swoole_process::name(): swoole_set_process_name is not supported on MacOS
这个警告能否做一下判断,在MacOS下不执行swoole_set_process_name
这个和workman对比有什么优势
Bug report? | yes
swoft | beta
swoole | 2.1.0
| PHP version 7.1.14 (cli) (built: Feb 2 2018 08:42:59) ( NTS )
mac 环境
Details
用postman 上传文件,几兆的小文件上传都成功了,但是上传120兆的csv,postman无法获得任何响应,直接报错了,程序当中也没有任何异常输出
没有异常输出
Provide minimal script to reproduce the issue
/**
* @RequestMapping(route="/test/upload",method=RequestMethod::POST)
*
* @param Request $request
* @return array
*/
public function test(Request $request)
{
$id = (int)$request->input('bookId');
if(empty($id)){
return ["need id"];
}
$file = $request->file("book");
if ($file instanceof UploadedFileInterface) {
$type = $file->getClientMediaType();
if($type == "text/csv"){
try {
$file->moveTo('@runtime/uploadfiles/book_'.$id.".csv");
$move = "success";
} catch (\Throwable $e) {
var_dump($e);
$move = "false";
}
}
}
return compact('move');
}
App::$server return null
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.