hhxsv5 / laravel-s Goto Github PK
View Code? Open in Web Editor NEWLaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
License: MIT License
LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
License: MIT License
怎么打log?只能用file_put_contents这个函数么?貌似也不能正确打日志,感觉调试好麻烦
Tell us your PHP version(php -v
)
7.2.6
TODO
Tell us your Swoole version(php --ri swoole
)
4.0.0
TODO
Tell us your Laravel
/Lumen
version(check composer.json & composer.lock)
5.5.33
TODO
Detail description about this issue(error/log)
error
TODO
Give us a reproducible
code block and steps
//TODO: Your code
使用协程mysql普通业务逻辑查询,大概有6人同时使用
local.ERROR: Swoole\Coroutine\MySQL::prepare(): mysql client is waiting response, cannot send new sql query. (SQL: select did
from sys_district
where pk_corp
= 1121 and sys_district
.deleted_at
is null limit 1) {"exception":"[object] (Illuminate\Database\QueryException(code: 0): Swoole\Coroutine\MySQL::prepare(): mysql client is waiting response, cannot send new sql query. (SQL: select did
from sys_district
where pk_corp
= 1121 and sys_district
.deleted_at
is null limit 1) at /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, ErrorException(code: 0): Swoole\Coroutine\MySQL::prepare(): mysql client is waiting response, cannot send new sql query. at /data/nginx/pm-api/vendor/hhxsv5/laravel-s/src/Illuminate/Database/CoroutineMySQL.php:23)
[stacktrace]
#0 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('select did
fr...', Array, Object(Closure))
#1 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\Database\Connection->run('select did
fr...', Array, Object(Closure))
#2 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1707): Illuminate\Database\Connection->select('select did
fr...', Array, true)
#3 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1692): Illuminate\Database\Query\Builder->runSelect()
#4 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(479): Illuminate\Database\Query\Builder->get(Array)
#5 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(463): Illuminate\Database\Eloquent\Builder->getModels(Array)
#6 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(77): Illuminate\Database\Eloquent\Builder->get(Array)
#7 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(445): Illuminate\Database\Eloquent\Builder->first(Array)
#8 /data/nginx/pm-api/app/Http/Middleware/CheckSign.php(37): Illuminate\Database\Eloquent\Builder->value('did')
#9 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\CheckSign->handle(Object(Illuminate\Http\Request), Object(Closure))
#10 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
"laravel-2018-07-04.log" 35410L, 6468760C
#39 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#41 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#44 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#45 /data/nginx/pm-api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#46 /data/nginx/pm-api/vendor/hhxsv5/laravel-s/src/Illuminate/Laravel.php(184): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#47 /data/nginx/pm-api/vendor/hhxsv5/laravel-s/src/LaravelS.php(165): Hhxsv5\LaravelS\Illuminate\Laravel->handleDynamic(Object(Illuminate\Http\Request))
#48 /data/nginx/pm-api/vendor/hhxsv5/laravel-s/src/LaravelS.php(123): Hhxsv5\LaravelS\LaravelS->handleDynamicResource(Object(Illuminate\Http\Request), Object(Swoole\Http\Response))
#49 {main}
"}
Tell us your PHP version(php -v
)
7.2.5
Tell us your Swoole version(php --ri swoole
)
2.1.3
Tell us your Laravel
/Lumen
version(check composer.json & composer.lock)
5.6.21
Detail description about this issue(error/log)
用laravels做http服务器,在使用laravel-admin后台导出cvs文件时报错500
laravels log会记录文件信息
而使用nginx则会直接输出cvs文件以供下载
laravels输出格式问题吗?
reproducible
code block and steps
不知道哪一步出问题了,使用的lumen5.5版本 nginx/1.12.0
我的运行环境如下:
+-------------------+------------------------------------------+
| Component | Version |
+-------------------+------------------------------------------+
| PHP | 7.2.4 |
| Swoole | 2.1.3 |
| Laravel Framework | Lumen (5.5.2) (Laravel Components 5.5.*) |
+-------------------+------------------------------------------+
config/cache.php 相关配置:
'default' => env('CACHE_DRIVER', 'redis'),
'stores' => [
'redis' => [
'driver' => 'redis',
'connection' => env('CACHE_REDIS_CONNECTION', 'default'),
],
执行步骤:
开启websocket服务,
在postman中请求一个api接口(有启用throttle中间件),
第一次返回正常,第二次报错:
Oops! An unexpected error occurred: Cache store [] is not defined.
错误日志:
[ERROR] LaravelS: onRequest: Uncaught exception "InvalidArgumentException"([0]Cache store [] is not defined.) at /xxx/vendor/illuminate/cache/CacheManager.php:96,
#0 /xxx/vendor/illuminate/cache/CacheManager.php(80): Illuminate\Cache\CacheManager->resolve(NULL)
#1 /xxx/vendor/illuminate/cache/CacheManager.php(58): Illuminate\Cache\CacheManager->get(NULL)
#2 /xxx/vendor/illuminate/cache/CacheManager.php(69): Illuminate\Cache\CacheManager->store(NULL)
#3 /xxx/vendor/illuminate/cache/CacheServiceProvider.php(28): Illuminate\Cache\CacheManager->driver()
#4 /xxx/vendor/illuminate/container/Container.php(749): Illuminate\Cache\CacheServiceProvider->Illuminate\Cache{closure}(Object(Laravel\Lumen\Application), Array)
#5 /xxx/vendor/illuminate/container/Container.php(631): Illuminate\Container\Container->build(Object(Closure))
#6 /xxx/vendor/illuminate/container/Container.php(586): Illuminate\Container\Container->resolve('cache.store', Array)
#7 /xxx/vendor/laravel/lumen-framework/src/Application.php(230): Illuminate\Container\Container->make('cache.store', Array)
#8 /xxx/vendor/illuminate/container/Container.php(885): Laravel\Lumen\Application->make('cache.store')
#9 /xxx/vendor/illuminate/container/Container.php(813): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#10 /xxx/vendor/illuminate/container/Container.php(780): Illuminate\Container\Container->resolveDependencies(Array)
#11 /xxx/vendor/illuminate/container/Container.php(631): Illuminate\Container\Container->build('Tymon\JWTAuth\P...')
#12 /xxx/vendor/illuminate/container/Container.php(586): Illuminate\Container\Container->resolve('Tymon\JWTAuth\P...', Array)
#13 /xxx/vendor/laravel/lumen-framework/src/Application.php(230): Illuminate\Container\Container->make('Tymon\JWTAuth\P...', Array)
#14 /xxx/vendor/tymon/jwt-auth/src/Providers/AbstractServiceProvider.php(377): Laravel\Lumen\Application->make('Tymon\JWTAuth\P...')
#15 /xxx/vendor/tymon/jwt-auth/src/Providers/AbstractServiceProvider.php(201): Tymon\JWTAuth\Providers\AbstractServiceProvider->getConfigInstance('providers.stora...')
#16 /xxx/vendor/illuminate/container/Container.php(749): Tymon\JWTAuth\Providers\AbstractServiceProvider->Tymon\JWTAuth\Providers{closure}(Object(Laravel\Lumen\Application), Array)
#17 /xxx/vendor/illuminate/container/Container.php(631): Illuminate\Container\Container->build(Object(Closure))
#18 /xxx/vendor/illuminate/container/Container.php(586): Illuminate\Container\Container->resolve('tymon.jwt.provi...', Array)
#19 /xxx/vendor/laravel/lumen-framework/src/Application.php(230): Illuminate\Container\Container->make('tymon.jwt.provi...', Array)
#20 /xxx/vendor/illuminate/container/Container.php(503): Laravel\Lumen\Application->make('tymon.jwt.provi...')
#21 /xxx/vendor/illuminate/container/Container.php(238): Illuminate\Container\Container->rebound('tymon.jwt.provi...')
#22 /xxx/vendor/illuminate/container/Container.php(332): Illuminate\Container\Container->bind('tymon.jwt.provi...', Object(Closure), true)
#23 /xxx/vendor/tymon/jwt-auth/src/Providers/AbstractServiceProvider.php(202): Illuminate\Container\Container->singleton('tymon.jwt.provi...', Object(Closure))
#24 /xxx/vendor/tymon/jwt-auth/src/Providers/AbstractServiceProvider.php(75): Tymon\JWTAuth\Providers\AbstractServiceProvider->registerStorageProvider()
#25 /xxx/vendor/laravel/lumen-framework/src/Application.php(193): Tymon\JWTAuth\Providers\AbstractServiceProvider->register()
#26 /xxx/vendor/hhxsv5/laravel-s/src/Illuminate/Laravel.php(244): Laravel\Lumen\Application->register(Object(Tymon\JWTAuth\Providers\LumenServiceProvider), Array, true)
#27 /xxx/vendor/hhxsv5/laravel-s/src/Illuminate/Laravel.php(267): Hhxsv5\LaravelS\Illuminate\Laravel->reRegisterServiceProvider('\Tymon\JWTAuth\...')
#28 /xxx/vendor/hhxsv5/laravel-s/src/LaravelS.php(123): Hhxsv5\LaravelS\Illuminate\Laravel->cleanRequest(Object(Illuminate\Http\Request))
#29 /xxx/vendor/hhxsv5/laravel-s/src/LaravelS.php(78): Hhxsv5\LaravelS\LaravelS->handleDynamicResource(Object(Illuminate\Http\Request), Object(Swoole\Http\Response))
#30 {main}
如题,目前路由不起作用,还有就是,这个东西怎么设置env参数,比如用fastcgi的话是可以设置fastcgi_param这个的,意思是不写在项目里,在服务端设置
php -v
)php 7.1.7
php --ri swoole
)swoole 2.0.12
Laravel
/Lumen
version(check composer.json & composer.lock)laravel 5.6.2
1.登陆后打开websocked连接页面触发onOpen事件
2.注销用户登录(注销后后台首页已经不能访问了)
3.重复打开websocked连接页面触发onOpen事件
4.打开后台首页(此时又能正常访问),session又有了
感觉是Laravel的session清除后,onOpen事件中开启的Laravel生命周期还在,刷新一下连接又恢复原来的session了
php -v
)PHP 7.0.20-2 (cli) (built: Jun 14 2017 05:30:04) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.20-2, Copyright (c) 1999-2017, by Zend Technologies
php --ri swoole
)swoole
swoole support => enabled
Version => 2.1.3
Author => tianfeng.han[email: [email protected]]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
Laravel
/Lumen
version(check composer.json & composer.lock)"laravel/framework": "5.5.*",
文件无法上传,一直处于loading状态,nginx是根据README里给出的配置弄的
reproducible
code block and steps
//TODO: Your code
php -v
)PHP 7.1.8
php --ri swoole
)4.0.0-alpha
Laravel
/Lumen
version(check composer.json & composer.lock)Laravel 5.6
不是用 laravels 是一切正常的,但是用后,每运行一段时间,jwt 的接口就会出现401,jwt 的 token 是新声称的(jwt的 token 是新生成的)。
尝试过把reactor_num
和worker_num
设置成1
,没有解决问题。
reproducible
code block and steps
middleware
public function handle($request, Closure $next)
{
$admin = auth()->user();
try {
// ...
} catch (\Exception $e) {
// 每次会走进来这里
throw new BadRoleException();
}
return $next($request);
}
laravels.php
'daemonize' => env('LARAVELS_DAEMONIZE', true),
'dispatch_mode' => 1,
'reactor_num' => 1,
'worker_num' => 1,
'task_ipc_mode' => 3,
'task_max_request' => 3000,
'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
'message_queue_key' => ftok(base_path('public/index.php'), 1),
'max_request' => 3000,
'open_tcp_nodelay' => true,
'pid_file' => storage_path('laravels.pid'),
'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))),
'log_level' => 5,
'document_root' => base_path('public'),
'buffer_output_size' => 32 * 1024 * 1024,
'socket_buffer_size' => 128 * 1024 * 1024,
'reload_async' => true,
'max_wait_time' => 60,
'enable_reuse_port' => true,
由于Lumen没有Laravel一样config/app.php 配置, 可以配置DatabaseServiceProvider
可以通过自定义 singleton 绑定 db来实现
在 App 下新建 一个 Application.php 文件.( 或者其他地方?)
Application 继承原有的 Laravel/Lumen/Application , 重写其中的 registerDatabaseBindings 方法, 使得其中 DatabaseServiceProvider 替换成 LaravelS 下的 DatabaseServiceProvider , 以实现跟 Laravel 中配置 config/app.php 替换一个效果.
<?php
namespace App;
use Laravel\Lumen\Application as LumenApplication;
class Application extends LumenApplication
{
public function __construct(?string $basePath = null) {
parent::__construct($basePath);
}
/**
* Register container bindings for the application.
*
* @return void
*/
protected function registerDatabaseBindings()
{
$this->singleton('db', function () {
return $this->loadComponent(
'database', [
'Hhxsv5\LaravelS\Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
], 'db'
);
});
}
}
在 bootstrap/app.php 中修改 Line 22 附近, 使用新建的 Application .
//$app = new Laravel\Lumen\Application(realpath(__DIR__ . '/../'));
$app = new \App\Application(realpath(__DIR__ . '/../'));
php -v
)PHP 7.2.6 (cli) (built: May 26 2018 07:45:18) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
php --ri swoole
)
swoole support => enabled
Version => 2.2.0
Author => tianfeng.han[email: [email protected]]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
Laravel
/Lumen
version(check composer.json & composer.lock)Lumen (5.6.3)
If you use Dingo api from the second response the data misses the "data" wrapper set in a provider (DataArraySerializer). Even if I re register with the config, the wrapper does not come back.
reproducible
code block and steps
The provider where I set thhe response adapter to DataArraySerializer:
<?php
namespace App\Providers;
use League\Fractal\Manager;
use Dingo\Api\Transformer\Factory;
use Illuminate\Support\ServiceProvider;
use Dingo\Api\Transformer\Adapter\Fractal;
use League\Fractal\Serializer\DataArraySerializer;
class DingoServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
public function boot()
{
app(Factory::class)->setAdapter(function ($app) {
return new Fractal(new Manager, 'include', ',');
});
app(Factory::class)->setAdapter(function ($app) {
$fractal = new Manager;
$fractal->setSerializer(new DataArraySerializer());
return new Fractal($fractal);
});
}
}
I register this in the bootstrap/app.php: $app->register(App\Providers\DingoServiceProvider::class);
On the first request/response the response is wrapped inside a "data" array. The second response gives exactly the same output, but without the data array wrapping.
First response:
{"data":[{"id":1,"name":"asd, ...}]}
Second response:
[{"id":1,"name":"asd, ...}]
I tried setting the "register_providers" array, and add the boot function lines to the register method.
The problem is, that the cleaning between two requests clears something and I cannot set it back.
php -v
)TODO
php5.6.33 php7.0.19
php --ri swoole
)TODO
php5.6.33->1.10.1 php7.0.19->2.0.9
Laravel
/Lumen
version(check composer.json & composer.lock)TODO
Lumenv5.2.5
TODO
php artisan laravels start
storage/logs/swoole-2018-06.log
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
但是不影响api接口调用
reproducible
code block and steps
//TODO: Your code
在laravels配置里找不到这个设置的位置...应该是swoole的文件上传大小限制,google都搜不到这几个名词
Tell us your PHP version(php -v
)
7.0.15
Tell us your Swoole version(php --ri swoole
)
4.0.1
Tell us your Laravel
/Lumen
version(check composer.json & composer.lock)
Laravel Framework | 5.4.36
Detail description about this issue(error/log)
[ERROR] LaravelS: Uncaught exception 'ErrorException': [0]Swoole\Server::task(): task method can only be used in the worker process.
Give us a reproducible
code block and steps
use App\Tasks\ExecuteTask;
use Hhxsv5\LaravelS\Swoole\Timer\CronJob;
class Timer extends CronJob
{
public function __construct()
{
}
public function interval()
{
return 1000;// Run every 1 minute
}
public function isImmediate()
{
return false;
}
public function run()
{
$task = new ExecuteTask(Task::find(1));
\Hhxsv5\LaravelS\Swoole\Task\Task::deliver($task);
}
}
class ExecuteTask extends \Hhxsv5\LaravelS\Swoole\Task\Task
{
}
app/config/laravels.php
'timer' => [
'enable' => true,
'jobs' => [
\App\Jobs\Timer::class,
],
],
'swoole' => [
'worker_num' => 8,
]
php artisan laravels:publish
应该改成php artisan laravels publish 吧?
已Star
情景:
我的程序里面有一个服务需要加载字典,字典内容多需要加载的时间长。因此我想把服务像laravel的app一样被laravels从入口处加载,这样就可以一次加载,后面所有请求都直接调用,免去每个请求都把它实例化一次,把字典重新读取一次这么浪费时间。
问题:
那么我应该怎么把这个加载字典的工具,跟laravel的框架一起实例化加载到swoole中运行呢?
php7.1.14 swoole2.0.7
Warning: Swoole\Server::on(): Unknown event types[WorkerExit] in /workspace/localsite/eMonitor/vendor/hhxsv5/laravel-s/src/Swoole/Server.php on line 54
第54行
if (version_compare(\swoole_version(), '1.9.17', '>=')) {
$this->swoole->on('WorkerExit', [$this, 'onWorkerExit']);
}
swoole2.0.7 的server里是不是没有了workerExit事件,swoole文档真tm差劲
请问何时可以支持swoole2.x
php -v
)7.1.18
php --ri swoole
)4.0.1
Laravel
/Lumen
version(check composer.json & composer.lock)TODO
It's a question rather than an issue. We're wondering if there is out of the box support for Broadcasts to support Laravel Echo. If so, are there any instructions on configuration?
By the looks of it, it doesn't seem like this is supported out of the box. However, the tools are provided to build the implementation.
Tell us your PHP version(php -v
)
7.1.14
TODO
Tell us your Swoole version(php --ri swoole
)
3.0.0-alpha
TODO
Tell us your Laravel
/Lumen
version(check composer.json & composer.lock)
5.5.40
TODO
TODO
Give us a reproducible
code block and steps
My nginx config file is the same as you suggested(I used ssl cr), my js code is like this
var ws = new WebSocket("wss://wqw.hfvi.cn/ws");
ws.onopen = function() {
console.log("send message");
};
ws.onmessage = function (evt) {
};
ws.onclose = function() {
};
//TODO: Your code
我在业务中有使用ob_flush
函数用来做持续输出,不过在laravelS无法输出,只输出到了日志文件里
echo "<script>parent.displayMsg(\"{$msg}\");</script>";
ob_flush();
flush();
重现curl如下
curl 'http://discover.vesync.com/api/deal/6' -H 'Content-Type: application/json;charset=UTF-8' -d 'a=1&b=2' -X 'POST'
去掉 -H 'Content-Type: application/json;charset=UTF-8' 就可以获取得到$request->input()
前端采用axios 异步提交 默认带上了这个头信息
用fpm方式laravel框架能够解析获取
php -v
)7.2.5
php --ri swoole
)2.0.7
Laravel
/Lumen
version(check composer.json & composer.lock)5.6.24
在Controller中,调用 $swoole = app('swoole'); 报错 Class swoole does not exist
一开始是页面会莫名的退出登录,然后再次尝试登录的时候就出错了。查看日志提示是 AuthManager 的某个方法未定义。
Method attempt does not exist. {“exception”:”[object] (BadMethodCallException(code: 0): Method attempt does not exist.
这就有点奇怪了,明明在 php-fpm 下啥事都没有。更加邪门的是,这个在正式环境下才有问题,测试环境下一点问题都没有。后来仔细排查,阅读了这部分的所有相关源码之后,发现 Auth driver 加载的居然是 api 的,然而这个是 web 的路由呀。仔细追查下去,发现是 Laravel passport 在加载时改写了 config,在调用 shouldUse 方法时,如果是 api 路由,就把默认的 driver 改成他自己了,这样在 api 路由当然没问题,可老铁。。。如果处理这个请求的 Worker 后来又去请求 web 了,默认的 driver 就一直是 api 了,所以才会出现上面这种情况。
知道是什么原因了,解决就好说了,把 config 给重置下,可怎么重置也略有点蛋疼。。。
生产环境是通过每次更新新tag的代码,然后修改软链接到线上环境,但是框架onWokerStart之前已经使用base_path获取了之前软连接的实际路径,导致reload不生效,是否有好的解决办法。
Tell us your PHP version(php -v
)
php7.2 + lumen
Tell us your Swoole version(php --ri swoole
)
3.0.0-alpha
Laravel
/Lumen
version(check composer.json & composer.lock)Lumen (5.6.3)
已经安装inotify拓展,版本为 2.0.0 但是更新代码后不生效,并且reload配置更新为true, 我是搭建在docker容器内的
reproducible
code block.env
LARAVELS_INOTIFY_RELOAD=true
php -v
)php 7.0.6
php --ri swoole
)2.1.3
Laravel
/Lumen
version(check composer.json & composer.lock)Laravel 5.2.45
站点是https的,在模板文件中引入css文件
<link rel="stylesheet" href="{{asset('/css/admin/bootstrap-multiselect.css')}}">
asset('/css/admin/bootstrap-multiselect.css')返回的URL是 http://xxxx 而不是 https://xxxx
https站点下尝试加载非https的内容,导致报错
通过追查asset()函数,最终发现是根据$_SERVER['HTTPS']的值来决定以https或以http开头生成URL
对比nginx+phpfpm,nginx+laravelS除$_SERVER['HTTPS']以外,还少了不少字段,如:
SERVER_NAME、REQUEST_SCHEME
用apache访问静态资源,php反向代理给laravel-s
php -v
)7.1.16
php --ri swoole
)4.0.0-beta
Laravel
/Lumen
version(check composer.json & composer.lock)5.5.40
使用第三方库flash做表单验证提醒,当第一次提醒成功时候有一次提醒,当第二次成功的时候有两个提醒,每次会增多,刷新都没用,而在fpm下运行不会出现此结果,该库的地址https://github.com/laracasts/flash,麻烦大神帮我看看
reproducible
code block and steps
// controller
flash("添加成功")->success()->important();
return view('test');
// view
@extends('layouts.app')
@section('content')
@include('flash::message')
@endsection
| PHP | 7.1.17 |
| Swoole | 2.1.3 |
| Laravel Framework | 5.6.26
upstream timed out (110: Connection timed out) while reading response header from upstream
reproducible
code block and steps
app.php 中替换了 databaseServiceProvider
database.php 的配置:
'mysql' => [
'driver' => 'sw-co-mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
`
TestController
```php
public function index() {
$res = Post::where('id',1)->get();
return response()->json($res->toArray());
}
`
使用
```php
DB::select('SELECT * FROM posts WHERE id=1');
`
也是一样的效果.
Nginx配置同文档一致, 使用 php artisan laravels start 启动.
php -v
)TODO
php --ri swoole
)TODO
Laravel
/Lumen
version(check composer.json & composer.lock)TODO
TODO
reproducible
code block and steps
//TODO: Your code
在控制器用$request->getContent()能接收到类似string(75) "nick_name=1231231&email=fdkljfkdjfkd%40djfkdjfkd.cn &password=jkfjdkfjdkfjdk"的数据;$request->input()接收为空
自己配置了下,部分链接不能访问
Tell us your PHP version(php -v
)
7.2.6
TODO
Tell us your Swoole version(php --ri swoole
)
4.0.0
TODO
Tell us your Laravel
/Lumen
version(check composer.json & composer.lock)
5.5.33
TODO
Detail description about this issue(error/log)
error
TODO
Give us a reproducible
code block and steps
//TODO: Your code
public function test (Request $request)
{
$data = DB::transaction(function (){
return DB::transaction(function (){
return ['a' => 1];
});
});
return $this->apiResponse(0, "success", $data);
}
php -v
)PHP 7.2.5 (cli) (built: May 11 2018 17:15:07) ( NTS )
php --ri swoole
)Version => 2.1.3
Laravel
/Lumen
version(check composer.json & composer.lock)Laravel version | 5.6.21
websocket新连接fd自增总会跳过一个,比如当前fd 4,下一个连接就会变成6而不是5
是设定原因还是bug?
reproducible
code block and steps
[2018-06-06 11:06:10] local.INFO: New Websocket connection [2]
[2018-06-06 11:06:14] local.INFO: New Websocket connection [4]
[2018-06-06 11:06:16] local.INFO: New Websocket connection [6]
我想请教下,在第一个配置(我认为是http)和websocket服务器下的配置有什么区别呢?
在websocket下配置nginx,无法访问public下的静态资源文件,配置内容是直接粘贴的。
而且在第一个配置下也是可以用websocket的呀
[2018-02-07 14:54:30 *154.0] ERROR zm_deactivate_swoole (ERROR 503): Fatal error: Uncaught Error: Call to undefined method swoole_http_response::gzip() in /var/www/tanteng.me/vendor/hhxsv5/laravel-s/src/Swoole/DynamicResponse.php:13 Stack trace: #0 /var/www/tanteng.me/vendor/hhxsv5/laravel-s/src/Swoole/Response.php(54): Hhxsv5\LaravelS\Swoole\DynamicResponse->gzip() #1 /var/www/tanteng.me/vendor/hhxsv5/laravel-s/src/LaravelS.php(84): Hhxsv5\LaravelS\Swoole\Response->send(1) #2 /var/www/tanteng.me/vendor/hhxsv5/laravel-s/src/LaravelS.php(59) [2018-02-07 14:54:30 $113.0] WARNING swManager_check_exit_status: worker#0 abnormal exit, status=255, signal=0
安装了 ziplib 模块还是不行,环境 PHP7 + Swoole 最新版
可以支持热重启吗
In LaravelSCommand.php line 69:
Call to undefined function swoole_version();
我已经安装好了swoole 2.1.1,phpinfo里已经显示enable
环境centos lnmp
PHP 版本号 7.2.4
SWOOLE版本号2.1.1
Laravel 版本号5.6
网站地址设置如果是非默认80,经过nginx + laravels处理后路由地址不带端口号,导致路由错误
var_dump(env('APP_URL'))----->http://xxxx:8081
var_dump(URL::current())------>http://xxxx
环境配置
.env
APP_URL=http://xxxx:8081
config/app.php
'url' => env('APP_URL', 'http://xxxx:8081'),
错误展示
var_dump(env('APP_URL'))----->http://xxxx:8081
var_dump(URL::current())------>http://xxxx
以上问题放弃nginx + laravels 仅使用apache提供服务则完全正常
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.