1. Asynchronous PHP is possible using options like PThreads or forks to allow non-blocking operations.
2. Asynchronous PHP can be useful for applications that spend a lot of time waiting, like websockets.
3. ReactPHP is a popular option for asynchronous PHP that uses a reactor pattern similar to Twisted or Node.js and includes Ratchet for websockets support.
2. Hi!
Im Chris
Supposedly, I love PHP. But can it really be loved?
You want to contact me? Write, and perhaps Ill write back:
/krzysztofozog
3. A few words about me...
A Philosopher and a Developer in one
Whats even worse is that its documented with two diplomas
Although, more of a developer:
A creator of web apps for more than a decade now
Created my first PHP app in 2004
Addicted to clean code
Technical leader at Codesushi
A passionate CodeReviewer
4. The agenda of this grand meeting
1. Asynchronous PHP is it even possible?
2. What can it be useful for?
3. A word or two about... reactPHP
4. Fine words butter no parsnips, meaning
Promises in PHP
6. Asynchronicity in PHP?
Asynchronous vs. multithreading vs.
forking a revision of terms
Asynchronicity is more of a philosophy
than a specific mode of implementation
What are the available options with PHP
PThreads
Forks (PCNTL)
8. Using an asynchronous PHP
First of all, there is no one universal rule!
We can use it everywhere where the app
spends much time waiting
Websockets
Should we start writing in an
asynchronous mode all the time now?
- No!
9. So the most popular option
for an Asynchronous PHP
3.
reactPHP
10. Exists since 2012 (current version - 0.4.2)
Reactor pattern (as Twisted or nodejs)
Ratchet websockets on react
12. Promises
What is a promise? - Syntactic sugar
Two main implementations in php
Guzzle/promises
reactphp/promise
Using promises:
Simultaneous queries to api [Guzzle]
Organizing an asynchronous code
13. Summary
Asynchronous PHP its possible!
No sense in using it everywhere
ReactPHP may be helpful
Promises can also be used independently
14. Thank you for your attention!
Questions?
If needed, it will be easier to reach me this way:
/krzysztofozog
chris@codesushi.co