Gunah Gaar
Gunah Gaar

Reputation: 535

websockets and PHP basics and initiatives

I have to built a multilayer game using web-sockets. For this I have a a shared web server with Apache. Browser is not an issue I am building for modern browsers only. I tried few example PHP and web-socket source code but no luck. What do I need to do? And also how to enable the PHP socket_create function? Already enables php_sockets extension in the php.ini and also the php_sockets.dll exists in the extension directory. When I call socket_create function php says that this function is undefined.

Any kind of help is appreciated. Thanks

Upvotes: 0

Views: 1378

Answers (2)

leggetter
leggetter

Reputation: 15467

If you can guarantee WebSocket support in the browser then use Ratchet. It won't run within Apache, but as a separate process.

There are other options available too - see the realtime web tech guide.

Questions related to WebSocket + PHP have been asked a number of times on SO. I'd recommend doing a search for best solutions and known gotchas when using Apache, PHP + WebSocket. Here's are a couple of good starting question with some additional links in the answers:

Upvotes: 1

Shahid Karimi
Shahid Karimi

Reputation: 4357

It seems that the command prompt was using a different configuration file for PHP.

Apache (or from the WAMP's interface) uses a php.ini that is located at:

 [WAMP_DIRECTORY]\bin\apache\Apache2.2.21\bin\php.ini

If you will open this file, you may notice that the line extension=php_sockets.dll is already commented out.

Unfortunately, the CLI or command line interface is using a different configuration file which is located at:

 [WAMP_DIRECTORY]\bin\php\php5.3.8\php.ini

In order to resolve it, you should comment out the line extension=php_sockets.dll and save it. Run the program after to see if the websockets again are already up and working.

Upvotes: 1

Related Questions