Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PHP Reactive Programming

You're reading from   PHP Reactive Programming Build fault tolerant and high performing application in PHP based on the reactive architecture

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher Packt
ISBN-13 9781786462879
Length 364 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Martin Sikora Martin Sikora
Author Profile Icon Martin Sikora
Martin Sikora
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Introduction to Reactive Programming 2. Reactive Programming with RxPHP FREE CHAPTER 3. Writing a Reddit Reader with RxPHP 4. Reactive versus a Typical Event-Driven Approach 5. Testing RxPHP Code 6. PHP Streams API and Higher-Order Observables 7. Implementing Socket IPC and WebSocket Server/Client 8. Multicasting in RxPHP and PHP7 pthreads Extension 9. Multithreaded and Distributed Computing with pthreads and Gearman 10. Using Advanced Operators and Techniques in RxPHP Appendix. Reusing RxPHP Techniques in RxJS

What this book covers

Chapter 1, Introduction to Reactive Programming, explains definitions of typical programming paradigms such as imperative, asynchronous, functional, parallel, and reactive programming. We’ll see what are the prerequisites to use functional programming in PHP and how all this is related to Reactive Extensions. At the end, we’ll introduce the RxPHP library as a tool of choice for this entire book.

Chapter 2, Reactive Programming with RxPHP, presents the basic concepts and common terminology used in reactive programming with RxPHP. It introduces Observables, observers, operators, Subjects, and disposables as the building blocks of any Rx application.

Chapter 3, Writing a Reddit Reader with RxPHP, builds on the knowledge from the previous chapter to write a Reddit reader application internally based on RxPHP. This will require downloading data via cURL and handling user input, and comparing the difference between blocking and non-blocking code in PHP in relation to RxPHP. We’ll also have a sneak peak into using event loops in PHP.

Chapter 4, Reactive versus a Typical Event-Driven Approach, shows that in order to use Rx in practice, we need to know how can we combine RxPHP code with some already existing code that isn’t based on Rx. For this reason, we’ll take the Event Dispatcher component that comes with the Symfony3 framework and extend it with Rx functionality.

Chapter 5, Testing RxPHP Code, covers testing, which is a crucial part of every development process. Apart from PHPUnit, we’ll also use the special testing classes that come with RxPHP out of the box. We’ll also take a look at testing asynchronous code in general and what caveats we need to be aware of.

Chapter 6, PHP Streams API and Higher-Order Observables, introduces the PHP Streams API and event loops. These two concepts are tightly coupled in RxPHP and we’ll learn why and how. We’ll talk about the issues we can encounter when using multiple event loops in the same application and how the PHP community is trying to solve them. We’ll also introduce the concept of higher-order Observables as a more advanced functionality of Rx.

Chapter 7, Implementing Socket IPC and WebSocket Server/Client, demonstrates how in order to write a more complicated asynchronous application, we’ll build a chat manager, server, and client as three separate processes that communicate with each other via Unix sockets and WebSockets. We’ll also use in practice the higher-order Observables from the previous chapter.

Chapter 8, Multicasting in RxPHP and PHP7 pthreads Extension, introduces us to the concept of multicasting in Rx and all the components that RxPHP provides for this purpose. We’ll also start using the pthreads extension for PHP7. This will let us run our code in parallel in multiple threads.

Chapter 9, Multithreaded and Distributed Computing with pthreads and Gearman, wraps the knowledge of pthreads from the previous chapter into reusable components that can be used together with RxPHP. We also introduce the Gearman framework as a way to distribute work among multiple processes. In the end, we’ll compare the pros and cons of using multiple threads and processes to run tasks in parallel.

Chapter 10, Using Advanced Operators and Techniques in RxPHP, will focus on not-so-common principles in Rx. These are mostly advanced operators for very specific tasks, but also implementation details of RxPHP components and their behavior in specific use cases that we should be aware of.

Appendix, Reusing RxPP Techniques in RxJS, demonstrates with practical examples how to deal with typical use cases where either RxPHP or RxJS come in handy. We'll see how asynchronous programming is used in a JavaScript environment and compare it to PHP. This final chapter also goes into more detail about what RxJS 5 is and how it differs from RxPHP.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime