Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with Swoole's defer() function in Laravel #52800

Closed
josecl opened this issue Sep 15, 2024 · 4 comments · Fixed by #52801
Closed

Conflict with Swoole's defer() function in Laravel #52800

josecl opened this issue Sep 15, 2024 · 4 comments · Fixed by #52801
Labels

Comments

@josecl
Copy link
Contributor

josecl commented Sep 15, 2024

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 introduced defer() 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

@staudenmeir
Copy link
Contributor

Please see laravel/octane#948.

@josecl
Copy link
Contributor Author

josecl commented Sep 16, 2024

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

@BassemN
Copy link
Contributor

BassemN commented Sep 16, 2024

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.

@josecl
Copy link
Contributor Author

josecl commented Sep 16, 2024

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:

laravel/sail#727
#52801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants