swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.04k stars 389 forks source link

mysql-coroutine How do you use it? #173

Closed dahuicyh closed 5 years ago

dahuicyh commented 5 years ago

Make sure you read Issues Guideline and answer these questions before submitting your issue. Thanks! (Any non-English issues will be closed immediately.)

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole) PHP 7.2 swoole:4.0.4

  2. Please provide your Laravel/Lumen version. lumen:5.6

  3. Which release version of this package are you using? 2.5

  4. What did you do? If possible, provide a recipe for reproducing the error.

I want to use MySQL protocol, how to configure it!

This is my current configuration:(app.php)

$app->configure('swoole_http'); $app->configure('swoole_websocket');

$app->register(SwooleTW\Http\LumenServiceProvider::class);

The MySQL protocol has not been found to be in effect?

damonto commented 5 years ago

You can change the driver to mysql-coroutine in config/database.php

damonto commented 5 years ago

If you are using Lumen you should add LumenServiceProvider::class before $app->withEloquent()

damonto commented 5 years ago

160 #165

dahuicyh commented 5 years ago

@damonto I installed it by composer, so what should I do about it?

"swooletw/laravel-swoole": "^2.5",

now: https://github.com/swooletw/laravel-swoole/tree/develop not in composer

damonto commented 5 years ago

"swooletw/laravel-swoole" : "dev-develop". NOT RECOMMEND.

dahuicyh commented 5 years ago

@damonto thank you very much

Now a new error: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught ErrorException: Swoole\Coroutine\MySQL::prepare(): mysql client is waiting response, cannot send new sql query.

wait 1 min response

albertcht commented 5 years ago

Hi @Leon-zzk ,

It doesn't support create another sub coroutine on your own at this moment.

Also, the coroutine feature is still in develop, it's not recommended to use coroutine client yet. Otherwise your some bindings in your app container will get polluted easily if you access them by Facades or static props.