I’m not seeking help for a specific problem. I think my question would benefit the community and encourage insightful discussion in general, but if the mods think my post goes against the rules then I understand…

I have a lot of experience building backend services with Node.js, Docker, and Kubernetes, and I’d like to transfer those skills to PHP, mainly because I’m starting a new job that uses it. In particular, I’m really interested in resources for learning best practices and examples in building distributed systems and microservices in PHP.
I know there are a lot of web frameworks for PHP, like Lumen and Laravel, and I reckon I should dust off my PHP skills (I know the basics and. have used it at work before), learn one of those frameworks, and structure it like a distributed app I’ve written in Node.
I’ve tried searching on my own without much luck, and I was wondering if you guys know about any books, resources, or courses that discuss building distributed backend systems with a cloud provider (like GCP or AWS) using modern PHP. I’m not really seeking a primer or tutorial of the basics of the language as I’ve already got some experience in prior jobs.
Thanks!
There is (almost) nothing on an architectural level that PHP will enable you or disable you from doing. If you are designing on the level of a microservices architecture, choice of language for one service is just an implementation detail. Use PHP for a service if it has some killer library or framework that is suited to your use case, or maybe you have a team of people who happen to be good with PHP.
My biggest question about microservices his how would each microservice share the database or will they have their own databases.. then how will you sync it up across other microservices?
That is up to you. You can choose to make your micro service stateless, or communicate with another service to get data, or connect directly to your database instance with an SQL connection.
A common way with Amazon Web Services is to use an EC2 instance for your main monolithic code base, then use lambda or more EC2 instances for the services/micro services. Then your database can use Amazon RDS which anything can connect to if it wants.
Just remember, disk IO is slow. So you should consider that in your software design to avoid RDS from being the part of the system that needs to pick up the slack from the rest.
Sharing the database is considered the #1 mistake in creating microservices. It makes services depend on each other, and database structure changes can cause unexpected problems at places where you did not expect them. Each microservice should have an isolated view on the domain it is active in. Copying or caching data between services thereby is not a problem, as the other service serves a different use case and thereby uses that same data differently. The storage technique for the exact same data even could be different (e.g. from memory vs from filesystem).
For distributed systems you could look into http://gearman.org/ .
Also https://reactphp.org/ offers a collection of libraries wich can help you in developing microservices and async interaction with other processes.

I came across this article a few years back that was great. It has example code for Lumen and a repo to reference. Essentially you put your other micro service apps behind a gateway app that fetches and builds the response from the registered services asynchronously.
https://medium.com/@poweredlocal/developing-a-simple-api-gateway-in-php-and-lumen-f84756cce043
You shouldn’t limit yourself looking specifically for microservices in PHP. I haven’t. Distributed systems and microservices is more about design patterns and the design of the solution.
SOLID principles and specifically Domain Driven Design is what I find to do the job better when building a microservice (or any service really). Heavy usage of caching in everything that you can is extremely helpful in order to get the speeds.
Microsoft’s msdn for building microservices is, from what I have seen, the best explaining core concepts of distributed systems with examples when it comes to free online resources. Generally the patterns that you can find in C#/Java can be applied to PHP.
https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/ for the Microsoft docs. (I am only pointing to one article, the whole chapter and e-book is useful)
Domain Driven Design, also known as the “Big Blue Book” of Eric Evans is highly appreciated based on Stackoverflow surveys: https://domainlanguage.com/ddd/blue-book/
In addition, the DDD in PHP book also is great, and is based on the blue book: https://github.com/dddinphp
Not sure of any books. But I would look towards React PHP, Ratchet and even more so Swoole frameworks. Swoole is more or less the Node.js of PHP (IMO).
Any resource about learning more about microservices in php?
I’ve been having a lot of fun with RabbitMQ consumers.
Doing simple things like offloading mails from the website’s main processes to a dedicated consumer (effectively removing the SMTP mail delay). Or performing scheduled tasks that can be run asynchronously by dumping the tasks into a queue with multiple listeners.
Because the consumers have access to the same domain logic as the websites, it makes it trivial to add things like…templated email bodies. Not having to update multiple domains in multiple languages feels really good.
I just started a job where I am required to know a lot about micro services. Dockerising apps and using kunernetes and the like. We’re there any tutorials that you found helpful? I’m somewhat new to using AWS/ Kube !!
I have very little experience building microservices in PHP – I mainly work with one macroservice – but you should look at https://amphp.org/ and/or https://reactphp.org/ for concurrent PHP, and also https://bref.sh/ for AWS-hosted PHP.
You will find that PHP isn’t ideal for microservices. It can undeniably do the job, but if you’re building everything from scratch a language like Go or Python may be slightly better-suited to the task.
Care to expand a bit on “… PHP isn’t ideal for microservices …” part? I am curious because I haven’t encountered any issues really. What part doesn’t do the job?

PHP isn’t
ideal
Maybe that was true before php 7, but that sure as heck is not true now.
I did something before with just regular PHP and AWS. Each service was basically just polling an SQS queue 24/7 and publishing to SNS.
Members
Online

source