Closed josecl closed 1 month ago
Please see https://github.com/laravel/octane/issues/948.
Please see laravel/octane#948.
Thank you for the context.
I believe this issue extends beyond Octane and impacts both the main framework and Sail
I believe the defer
function name is already registered with the Swoole
extension, which could cause conflicts with existing projects that rely on Swoole’s defer function or have the Swoole extension enabled. Unfortunately, I think Laravel should consider renaming the defer function to avoid these conflicts.
There is a workaround by disabling functions in Swoole with:
swoole.use_shortname = off
However, considering Laravel's history of prioritizing a frictionless developer experience, I believe a better long-term solution may be found.
For reference, see:
https://github.com/laravel/sail/pull/727 https://github.com/laravel/framework/pull/52801
Laravel Version
11.23.5
PHP Version
8.3.11
Database Driver & Version
No response
Description
I am currently using the Swoole 5.1.1 extension, which has implemented the
defer()
function since version 4.2.9. This function accepts a Closure as its first argument, leading to a conflict with Laravel's newly introduceddefer()
helper.The current implementation of Laravel's
defer()
involves using two classes, which can be a bit cumbersome to call directly. It would be helpful to consider providing a more convenient alternative, such as a dedicated Facade or another abstraction, to avoid conflicts with Swoole's existing functionality and simplify usage.Please note the following classes:
Illuminate\Concurrency\ForkDriver
Illuminate\Concurrency\ProcessDriver
Illuminate\Concurrency\SyncDriver
These classes internally call the
defer()
function, which will cause conflicts when using the Swoole extension.Steps To Reproduce
Enable the Swoole extension and attempt to use the
defer()
helper function