Comments (11)
Try add db
to instances
or add Illuminate\Database\DatabaseServiceProvider::class
to providers
in config/swoole_http.php
.
from laravel-swoole.
It works! thank you!
from laravel-swoole.
Hi @megawubs ,
Is you code in the same request?
from laravel-swoole.
Yes, it's being preformed in a middleware
from laravel-swoole.
Hi @megawubs ,
Where did you define your $config
? How about using config()->set('foo', 'bar')
and see if config changes by config('foo')
?
from laravel-swoole.
ah, i see i missed that part from copy pasting.
The full code is:
$config = app('config');
$db = app('db');
$db->purge('mysql_database_1');
$db->purge('mysql_database_2');
$config->set('database.connections.mysql_database_1.database', 'database_5');
$config->set('database.connections.mysql_database_2.database', 'database_6');
$db->reconnect('mysql_database_1');
$db->reconnect('mysql_database_2');
i've tried it with different ways of resolving the config. That's not the problem. When i read out the config later, it is changed. Only, the database connection is not...
from laravel-swoole.
Hi @megawubs ,
Does this middleware work in the traditionally FPM?
from laravel-swoole.
Yes
from laravel-swoole.
Your tip to add db
to the instances
field helps a bit. But only for DB::*
calls, not for eloquent calls.
I've created a test application to be able to isolate the problem. You can see it here: https://github.com/megawubs/swoole-debug
The steps to reproduce are located in the readme.
When i add this: \Log::info('the connection is: ', (array)$this->connection);
on line 2588 in Illuminate\Database\Query\Builder
you can see that the connection does not change when using eloquent. (route /1
)
from laravel-swoole.
Hi @megawubs ,
I didn't clone your repo yet, but I think it is caused by Illuminate\Database\Eloquent\Model::class
. There are lots of statics in this model class. ConnectionResolver
is also called by static and it's only set once in service provider. This may cause static variable pollutions.
Did you try to add Illuminate\Database\DatabaseServiceProvider::class
to providers in config/swoole_http.php
? Not sure if it helps.
from laravel-swoole.
from laravel-swoole.
Related Issues (20)
- Hello, since the installation , mysql often reports an error. Why is this?
- WARNING Server::check_worker_exit_status(): worker(pid=690, id=14) abnormal exit, status=0, signal=9
- Routes file changes not picked up until I restart my Docker container HOT 1
- [question] does this support mysql persistent connection or mysql connection pooling HOT 1
- Hot reload not working HOT 2
- Swoole Kill Process Without Waiting For Http Call
- How did I know swoole is succefull applied on my environment HOT 1
- streamDownload not working and sometimes also throw "allowed memory size ... exhausted" HOT 2
- high latency after loop
- can a controller run out swoole HOT 1
- Err in line 8 of tests/fixtures/bootstrap/app.php
- Auth user problem on web socket connection HOT 1
- auth user class redis not fund
- [Question] How to change default base_path so file upload $directory will be default on public folder rather than the root laravel folder? HOT 2
- Socket.io client not work with Websockets implementation out of box
- timer
- 调用chatgpt的流式响应输出有问题 HOT 1
- 为什么在使用websocket服务时,触发on connect回调的时候发送消息给指定userid的人,自己也会收到消息 HOT 1
- facades are not safe to use inside coroutine for sure in this package. HOT 1
- swoole HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-swoole.