modular php microservices with Slim framework
customized backend solutions with a small footprint
Slim is a PHP micro framework which basically takes a HTTP request, calls a routine based on it and returns a response.
It relies on the same composer based environment like its bigger brothers laravel and symfony but is – how the name implies – reduced to the max.
This reduction comes with a little extra bootstrapping work. When bootstrapping is done you have a beautiful, flexible and powerful piece of software, which can provide a wide range of backend-services running on almost every webhost.
Adding the modules you need for your project with composer.
For instance:
- user management with sentinel
- guzzle http to run a proxy, e.g. for collecting data from web-APIs or sites
- you can borrow the ORM-Layer from laravel called Eloquent / Doctrine
- use a configurable logger like monolog
- do database migrations and inserting mock-data via phpmig
Together with some useful techniques we can build reliable HTTP-REST-API-Microservices.
I used this setup to develop the transver-database.
This server software is querying SurveyMonkey for new or edited surveys. This is done with guzzle http. It inserts this survey data into its own database and taking care of updating procedures. Also it provides some REST-routes which are then used by a react app. See it in action here.

Migrations
Handling database while development with migrations gives us a kind of revision management for databases and allows to integrate database operations into develop- and build-pipelines.

Testing fine-grained business logic
For a bigger project I once integrated Behaviour-Driven-Development (BDD) into Slim via the behat testing framework.
This allowed us to test even fine-grained business logic, which does not only depend on the application but also the underlying data.

Please see my Slim 4 Skeleton on GitHub.