Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying PHP Reactive Programming
  • Table Of Contents Toc
  • Feedback & Rating feedback
PHP Reactive Programming

PHP Reactive Programming

By : Sikora
2 (1)
close
close
PHP Reactive Programming

PHP Reactive Programming

2 (1)
By: Sikora

Overview of this book

Reactive Programming helps us write code that is concise, clear, and readable. Combining the power of reactive programming and PHP, one of the most widely used languages, will enable you to create web applications more pragmatically. PHP Reactive Programming will teach you the benefits of reactive programming via real-world examples with a hands-on approach. You will create multiple projects showing RxPHP in action alone and in combination with other libraries. The book starts with a brief introduction to reactive programming, clearly explaining the importance of building reactive applications. You will use the RxPHP library, built a reddit CLI using it, and also re-implement the Symfony3 Event Dispatcher with RxPHP. You will learn how to test your RxPHP code by writing unit tests. Moving on to more interesting aspects, you will implement a web socket backend by developing a browser game. You will learn to implement quite complex reactive systems while avoiding pitfalls such as circular dependencies by moving the RxJS logic from the frontend to the backend. The book will then focus on writing extendable RxPHP code by developing a code testing tool and also cover Using RxPHP on both the server and client side of the application. With a concluding chapter on reactive programming practices in other languages, this book will serve as a complete guide for you to start writing reactive applications in PHP.
Table of Contents (12 chapters)
close
close

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.

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY