php and node.js together
DESCRIPTION
This goes over a bit of what node.js is, why you might want to use it, and how to use it with your PHP projects.TRANSCRIPT
![Page 1: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/1.jpg)
PHP and node.js Together
5/15/2013 php|tek 2013
E-mail: [email protected]: @dragonmantank
App.net: @ctankersley
![Page 2: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/2.jpg)
Who Are You and Why Are You In My House At My Conference
Chris Tankersley Doing PHP for 9 Years Lots of projects no one uses, and a
few that some do TL;DR https://github.com/
dragonmantank
March 3rd, 2013 MidwestPHP 2
![Page 3: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/3.jpg)
What We’re Gonna Do
Go over what node.js is What good is node.js? Different ways to use it with PHP
5/15/2013 php|tek 2013
![Page 4: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/4.jpg)
What Is node.js?
5/15/2013 php|tek 2013
![Page 5: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/5.jpg)
The Abstract
node.js is a server-side implementation of the Google V8
JavaScript engine
In broad terms, it does the same job as PHP but with JavaScript
5/15/2013 php|tek 2013
![Page 6: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/6.jpg)
5/15/2013 php|tek 2013
![Page 7: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/7.jpg)
Advantages for node.js
It’s JavaScript npm is pretty awesome It’s fast There’s a huge community
5/15/2013 php|tek 2013
![Page 8: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/8.jpg)
Sample node.js app
It’s just JavaScript, nothing fancy
5/15/2013 php|tek 2013
![Page 9: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/9.jpg)
Little less trivial example
5/15/2013 php|tek 2013
![Page 10: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/10.jpg)
Lies Benchmarks
node.js
Silex
5/15/2013 php|tek 2013
![Page 11: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/11.jpg)
What can you use node.js for?
Background tasks Server-side scripts API endpoints Websites
5/15/2013 php|tek 2013
![Page 12: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/12.jpg)
Working with PHP
5/15/2013 php|tek 2013
![Page 13: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/13.jpg)
Call it through exec()
Call node.js just like any other program
5/15/2013 php|tek 2013
![Page 14: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/14.jpg)
Connect it to your database
5/15/2013 php|tek 2013
![Page 15: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/15.jpg)
Out of band work
Push something into a redis via PHP, and have node.js listen and react
5/15/2013 php|tek 2013
![Page 16: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/16.jpg)
Pubsub
PHP and node.js connect to a redis channel
PHP publish something to the channel
node.js gets the message and reacts Really good for reacting to events,
but requires node.js to be listening
5/15/2013 php|tek 2013
![Page 17: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/17.jpg)
Work Queues
Same idea, but the work sits there until someone deals with it
5/15/2013 php|tek 2013
![Page 18: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/18.jpg)
Websockets
Allows two-way communication from the browser to the server
Most browsers should support it Use socket.io to handle old browsers
5/15/2013 php|tek 2013
![Page 19: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/19.jpg)
Putting it all together
5/15/2013 php|tek 2013
![Page 20: PHP and node.js Together](https://reader034.vdocument.in/reader034/viewer/2022042614/5557d52dd8b42ab6258b496e/html5/thumbnails/20.jpg)
Questions?
5/15/2013 php|tek 2013