Using Slim3 For Micro-Services
Slim is a "Micro-Services" application framework. Slim provides a minimalistic environment which is very suitable for the development of micro-services.
Micro-Services (MSA), what are they exactly?
It's an archectural design pattnern most commonly used in Enterprise Application Development. It is also easy to get it confused with SOA (Service-Oriented Architecture), I have found that the primary difference is in the actual size of each service. One might also say that SOA is more of how applications communicate and a precursor to MSA.
A micro-service is what I consider to be the smallest peice of domain logic. For the work I do; I design APIs, a Micro-service API has only end-points that relate to the function of the system the micro-service is designed for. Keeping things extremely tiny results in a lot of benefits that large applications require like resilency and scalability.
Example: A User Creation MSA
- Account Service
- Permission Service
- Authentication Service
- Email Service
Using Domain Driven Design concepts we can think of the system like the following. The Back-End systems are seperated from the UI and there is an initial Back-End Application that acts as a proxy to the micro-services. In this case we are trying to create a new User. We would call the Account Service to generate the record. The system then would emit an application event which the Permissions Service and Authentication Service would listen for. In these services would apply a default template for Permissions, and generate authentication tokens. Finally The Email Service would listen for the new authentication service to finish and send out a new user email.
So why would I want to do this???
Yeah I know what you are thinking, it's a crazy amount of work. Those are just 4 of the services that you will need and all it does is; create a new user model, apply some permissions, hash a password and send an email. "I can do that all in a controller". Yes, you can. You can write procedural PHP to do all of those things and you should if you do not have a large user base! MSA should be applied correctly just like everything else!
Okay, well how does Slim help
Well Slim provides you an easy to use HTTP Component for your micro-service. It's only one piece of your puzzle. You will likely need many, many other pieces like Persistence, Caching, Events or Email. Slim includes a way to manage your application dependencies as well so you can keep your micro-services from initializing too many services.
MSA is really great for team environments
Even small teams can do amazing things with MSA; however the knowledge bar is quite high for developing MSA applications. It requires a great technical lead and excellent communication/documentation systems.