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

PHP 7.0 Support #357

Closed
titansoftime opened this issue Sep 4, 2015 · 12 comments
Closed

PHP 7.0 Support #357

titansoftime opened this issue Sep 4, 2015 · 12 comments
Labels

Comments

@titansoftime
Copy link

I just tried out the current build of php 7.0 with ratchet. Works great! Super happy about that.

One thing (and I know this isn't a ratchet issue exactly, but after hours of googling and tinkering I'm left without answers):

Is it possible to install the libevent extension with php7 or am I just going to have to wait till November for the official release (or probably later)? I've tried and tried and failed.

EDIT: I will say though, even without libevent, php7 is anywhere from about 25% to 50% faster than 5.6 in my app =]

@cboden
Copy link
Member

cboden commented Sep 6, 2015

Glad to hear everything works and with a performance gain to boot!

The PECL libevent extension hasn't had a release in two years so I'm not sure what to expect with PHP7. The event extension (uses the libevent lib as well) has an open issue to get it working with PHP7. I'd say keep an eye on that ticket and give it a shot when there's an update.

I'm going to close this issue as I/O is not something that's handled by Ratchet. Feel free to open this issue in reactphp/event-loop though.

@cboden cboden closed this as completed Sep 6, 2015
@cboden cboden added the question label Sep 6, 2015
@titansoftime
Copy link
Author

Gotcha, yea that's kinda what I figured. Thanks for the info =]

@titansoftime
Copy link
Author

titansoftime commented Jul 4, 2016

@cboden I got this working, here is how.

I used this libevent: https://github.com/expressif/pecl-event-libevent

Installed using the following instructions:

$ phpize7.0 (not just phpize, this threw me off)
$ ./configure --with-php-config=/usr/bin/php-config7.0 (I found pointing to the correct config path necesary, your path may be different)
$ make
$ make install

Then made sure the created libevent.so file was placed in the correct php extension directory and confirmed that extension=libevent.so was is my php.ini (CLI of course).

This also requires the current version of ratchet-php (actually React I think) otherwise you will get an error at line 301 of the file LibEventLoop.php. The change was $this->timerCallback = function ($_, $_, $timer) {... to $this->timerCallback = function ($_, $__, $timer) {....

I hope this helps someone.

@ghost
Copy link

ghost commented Oct 5, 2016

@titansoftime Would you mind to elaborate a bit? I'm having the exact same issue. Is Ratchet dead? it seems like alot of it's dependencies only have a beta branch. (And most have not had a release in quite some time...) libevent is only a beta branch, hasn't been released in forever, and isn't compatible with PHP7. I had one HELL of a time getting ZMQ up and working (which, by the way, is ALSO only in beta)

@titansoftime
Copy link
Author

No Ratchet is not dead. Make sure you are using the latest version.

http://socketo.me/docs/install

I am running it with PHP7 and it works super great. The downside is that libevent does not work under 7.0. I posted above how to kinda get it to work but it crashes. So no libevent for php7 (yet at least). Good news is PHP7 runs faster than PHP5.6 + libevent (for my setup anyway).

@ghost
Copy link

ghost commented Oct 5, 2016

Thanks for the quick reply. Ok, so don't use your instructions as it still crashes. I've written a small websocket server (following their chat tutorial) and I agree, it does work great. Did you find a way to access the server from another php script without zmq? I don't want to use beta software on what may very well become a production solution.

@titansoftime
Copy link
Author

I use the default build. Haven't had any issues whatsoever. Though my use case is somewhat simple. I run a React loop and send steady data updates to connected clients. Also I simply handle user submitted http requests. Nothing too fancy.

Most complicated thing I attempted was running each connection on a seperate thread which did not work.

http://stackoverflow.com/questions/25704251/using-php-pthreads-with-ratchet-websocket

@ghost
Copy link

ghost commented Oct 5, 2016

HEEEEY! That's pretty cool. it's a shame it didn't work out for you. I'm baffled at just how simple the "chat" server implementation is. is that REALLY that easy to build a websocket server? As in, could I expand on the "chat" class and build a game server for something like checkers? (I'm trying to think of how I would seperate each game on the server side, just by expanding on the "chat" class and encoding my messages as JSON)

@titansoftime
Copy link
Author

I have mine running a browser based mmo so yes absolutely.

See it in action titansoftime.com

On Oct 5, 2016 4:40 PM, "TyMeador73" notifications@github.com wrote:

HEEEEY! That's pretty cool. it's a shame it didn't work out for you. I'm
baffled at just how simple the "chat" server implementation is. is that
REALLY that easy to build a websocket server? As in, could I expand on the
"chat" class and build a game server for something like checkers? (I'm
trying to think of how I would seperate each game on the server side, just
by expanding on the "chat" class and encoding my messages as JSON)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#357 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGPxAyPTuyge_sP04TI6bkJV2KjKRn7Iks5qxBk6gaJpZM4F4NmC
.

@ghost
Copy link

ghost commented Oct 5, 2016

HOLY SH8T ON A SHINGLE NICE WORK MAN!!!!!! Your server is running on Ratchet? I'm registering this, I've MUST try this out! it looks amazing!

@ghost
Copy link

ghost commented Oct 5, 2016

Wait a second, where are you using the websockets? I only see AJAX requests being made?

@titansoftime
Copy link
Author

Once you are logged in. Title page and character select do not benefit from
ws.

On Oct 5, 2016 4:55 PM, "TyMeador73" notifications@github.com wrote:

Wait a second, where are you using the websockets? I only see AJAX
requests being made?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#357 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGPxA09iO1f3UtlQw2cc16KTE2ILawxfks5qxBzHgaJpZM4F4NmC
.

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

No branches or pull requests

2 participants