03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Real Time Chat 170<br />

1 "require" : {<br />

2 "laravel/framework" : "4.0.*",<br />

3 "cboden/Ratchet" : "0.3.*"<br />

4 },<br />

.<br />

This was extracted from composer.json.<br />

Follow that up with:<br />

1 composer update<br />

.<br />

Ratchet isn’t built specifically for Laravel 4, so there are no service providers for us to add.<br />

We’ll now have access to the Ratchet library for client-server communication, Bootstrap for styling<br />

the interface and EmberJS for connecting these two things together.<br />

ReactPHP<br />

Before we can understand Ratchet, we need to understand ReactPHP. ReactPHP was born out of<br />

the need to develop event-based, asynchronous PHP applications. If you’ve worked with Node.JS<br />

you’ll feel right at home developing applications with ReactPHP; as they share a similar approaches<br />

to code. We’re not going to develop our chat application in ReactPHP, but it’s a dependency for<br />

Ratchet…<br />

.<br />

You can learn more about ReactPHP at: http://reactphp.org/.<br />

Ratchet<br />

One of the many ways in which real-time client-server applications are made possible is by what’s<br />

called socket programming. Believe it or not; most of what you do on the internet depends on socket<br />

programming. From simple browsing to streaming — your computer opens a socket connection to a<br />

server and the server sends data back through it.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!