PHP Coach logo
Contact me

Requisites

In order to be able to make this course, you should take in account some points. All of them are important, so you will share the course with many more attendees, and we'll start working hands on from the very first minute.

No matter what OS you bring in your computer, but be sure that you know how to install, use and manage all the needed tools.

We have available some translations for this content - Spanish version

  Skeleton

As easy as it sounds, but most of the times, one of the most difficult part of any application. In this first block of the course, we will build what will be our basis project. What do you need to start from the scratch a new project where you will code your business logic on top of CQRS and Event-Driven architecture design? What are the basic package you really need in your project in order to start with the thinnest project in your sandbox?

This chapter will explore the foundations of DriftPHP, a new framework built on top of Symfony and ReactPHP components. We'll digg into the main parts of the framework and their potential.

  • Block duration - 3h
  • Layers definition
  • Install DriftPHP. Architecture and fundamentals.
  • Command Bus as the core member of the project
  • Commands, command handlers and middleware classes
  • Our first hello world on top of CQRS
  • Server support with DriftPHP. Server + Watcher.
  • Some benchmarking with AB

  Docker Basics

Nowadays, one the best way of making your application available for almost every developer and every modern deploy system is by adding docker support. Docker is quite easy if you understand its bases and purpose, and that will be our goal. Once we have a nice skeleton for our new hello world application, we will setup both the docker and docker-compose support, for delivering, testing and developing

The goal of this chapter will be adding both a basic development and testing support for our application. We will add some CircleCI support to add a hook for our pull requests

  • Block duration - 2h
  • Docker needed blocks
  • Docker composer for testing
  • Creating a base Dockerfile

  ReactPHP fundamentals

Working with ReactPHP is a completely new experience if you have never worked with an event-loop or a Promise. Things happen eventually, and this forces you to change your mindset about how your services should look like.

Because DriftPHP, for the very first time in a PHP framework, can handle ReactPHP responses, we will be able to apply all asynchronous concepts in our domain in a way you've never seen before.

After this chapter you will understand all ReactPHP fundamentals. A very important piece of the course.

  • Block duration - 3h
  • What an event-loop is?
  • What a promise is?
  • What a stream is?

  Domain Definition

Now we have a small service that runs as faster as it can run, but we only have a small hello world endpoint, and would be difficult for us to make som money just with this feature, so let's start with our domain.

And our project will be simple. We will craft a small microservice to take care about users. Not about a login system, nor a complex user management, but a simple and small user API, ready to:

  • Add a new User
  • Delete an existing User
  • Edit an existing User
  • List all users

That will be enough to start understanding some small things around architecture, like where to place our domain classes, what these classes should have and what should completely avoid, and how big this model can really be before start thinking of making a logical split.

After this chapter, everything should be working properly, in a synchronous way, and by saving absolutely everything in memory, what, even working as expected, wont be useful at all. But hey! is our first step :)

  • Block duration - 3h
  • Needs analysis
  • Model classes implementation
  • I/O repositories interfaces and in-memory implementation
  • Full testing of our needs, both unit and functional

  I/O Dependencies

So let's make it work properly by adding an extra layer in our project related to I/O operations. In our language, adding some repository implementations, like the User storage one.

All additions will have to be 100% covered by unit tests. We will see how trivial is, after all, and only if we make the right steps, to make all this happen properly and green tested.

After this chapter, the application will turn properly usable

  • Block duration - 2h
  • Mysql adapter for our persistence layer
  • Unit testing of new adapters

  Turning event-driven

After these last 5 chapters, we will all have a working service on top of ReactPHP, with some tested repository implementations and with some benchmarks that will prove that we have improved so much our experience on top of PHP. Great.

But we can do better. Much better. Incredibly better.

This final chapter will literally blow your mind, so starting working with events in our application, and basically thanks to what ReactPHP can really bring us in terms of asynchrony and non-blocking, we'll be able to turn our service much more scalable, uncoupling from the infrastructure and decreasing our response time and resources consumption even once more.

  • Block duration - 3h
  • Define some domain events
  • Introducing long-term memory repositories
  • Introduction to AMQP (RabbitMQ)
  • Deploying server + consumer combined services
  • Introduction to websockets