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

Possibility for pure PHP package #202

Closed
filips123 opened this issue Jun 28, 2019 · 6 comments
Closed

Possibility for pure PHP package #202

filips123 opened this issue Jun 28, 2019 · 6 comments

Comments

@filips123
Copy link

Is it possible to make pure PHP package for ZeroMQ, without any C code or additional extensions?

If it won't negatively affect performance, it would be very good, because it would enable easier installation (with Composer) and usage.

@ClosetGeek-Git
Copy link

ClosetGeek-Git commented Jul 4, 2019

First, the performance impact would be huge in many (most?) situations. This isn't considering PHP's performance compared to native as much as the fact that standard libzmq handles io in optimised threads, where pure PHP would at best be a single thread with non-blocking sockets. This fact alone also means that it isn't possible to follow zmqs official specs. In the future extensions like pth or pthreads could be used to do this in PHP userspace but currently both extensions have significant performance issues with intra-thread communication. Outside of this fact, yes it is possible. Search "PHP zmtp" and you can find limited examples of pure PHP scripts handling at least pub/sub and push/pull using standard PHP streams.

@filips123
Copy link
Author

Is it possible to then just create "polyfill" and use it when the extension is not available? Even if it is slow, it's better than nothing.

@ClosetGeek-Git
Copy link

ClosetGeek-Git commented Jul 4, 2019

This should be entirely possible but I can see it creating problems when used. For example, if the underlying framework makes it impossible for a consumer to keep up with a producer it's sure to fail.

@ClosetGeek-Git
Copy link

I think it's a good idea though as long as users understand the limitations

@zebastian
Copy link
Contributor

One way or the other: a possible pure php polyfill for php-zmq should be maintained in its own project.
Please reopen, if still relevant.

@ClosetGeek-Git
Copy link

ClosetGeek-Git commented Apr 7, 2020

It's entirely possible to set up a standard system socket using PHP, and entirely possible to process incoming/outgoing packets per zmtp specifications using PHP - it's just not possible to process the packets fast enough to work once put under any type of real load. This isn't a PHP issue. The polyfill WOULD be able to effectively keep-up with C (Java, etc) based implementations if they were using the same single-threaded/generic socket design.

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

No branches or pull requests

3 participants