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

Prepare for working with newer versions of OpenSwoole. #128

Open
wants to merge 3 commits into
base: 4.10.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions compat/openswoole.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use OpenSwoole\Util;

// @see https://github.com/mezzio/mezzio-swoole/issues/110#issuecomment-1500174967
// Override the swoole_set_process_name function
if (version_compare(phpversion('openswoole'), '22.0.0', '>=')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should check if openswoole extension is installed first

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if openswoole users added this workaround to their code this will cause errors. So this should also be wrapped in function_exists.

Verification is needed that vendor autoload files are included after root composer.json autoloading rules

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if openswoole users added this workaround to their code this will cause errors.

If there is a migration document I can document this. Ideally this package should take care of such differences and not the end user. I guess end users will be more than happy to have mezzio-swoole working out of the box without the need for them to provide custom code.

function swoole_set_process_name(string $process_name): void
{
Util::setProcessName($process_name);
}
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@
"autoload": {
"psr-4": {
"Mezzio\\Swoole\\": "src/"
}
},
"files": [
"compat/openswoole.php"
]
},
"autoload-dev": {
"psr-4": {
Expand Down