hhxsv5 / laravel-s

LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
MIT License
3.83k stars 472 forks source link

APP_RUNNING_IN_CONSOLE=false does not work #337

Open webard opened 3 years ago

webard commented 3 years ago
| Software | Version |
| --------- | --------- |
| PHP | 7.4.13 |
| Swoole | 4.5.9 |
| Laravel | 8.26.1 |

Tip included in KnownIssues.md to run telescope or debugbar is wrong. Adding APP_RUNNING_IN_CONSOLE to .env nothing change.

To properly run swoole, command must have this env variable in command:

APP_RUNNING_IN_CONSOLE=false php bin/laravels start
lscar commented 1 year ago
| Software | Version |
| --------- | --------- |
| PHP | 7.4.13 |
| Swoole | 4.5.9 |
| Laravel | 8.26.1 |

Tip included in KnownIssues.md to run telescope or debugbar is wrong. Adding APP_RUNNING_IN_CONSOLE to .env nothing change.

To properly run swoole, command must have this env variable in command:

APP_RUNNING_IN_CONSOLE=false php bin/laravels start
Software Version
PHP 8.1.15
Swoole 5.0.2
LaravelS 3.7.35
Laravel 9.52.4

I have the same problem and your solution is correct. I hope the author @hhxsv5 can update the error description of "KnownIssues.md" to avoid more people making mistakes

lscar commented 1 year ago

Using "APP_RUNNING_IN_CONSOLE=false" will cause the logging command logic to work incorrectly.

// file vendor/laravel/telescope/src/Telescope.php
// function start 
        if (! static::runningWithinOctane($app) &&
            (static::runningApprovedArtisanCommand($app) ||
            static::handlingApprovedRequest($app))
        ) {
            static::startRecording($loadMonitoredTags = false);
        }

If it is command input now(e.g. php bin/laravel info), the result of static::handlingApprovedRequest($app) is "true". $app->runningInConsole() has been unable to identify whether it is "command" or "request".

Using "APP_RUNNING_IN_CONSOLE=false" is only a temporary solution. Haven't thought of a perfect solution yet.

Please consider rewriting the "runningInConsole" method in the Laravel framework.