Laravel: Repository Pattern

Laravel and Eloquent offer a straightforward and powerful approach to database interaction, enabling easy data retrieval, saving, updating, and deletion from various points in an application. This simplicity, while beneficial, brings with it a significant challenge: it becomes all too easy to produce code that is tightly coupled and disorganized. This issue is particularly evident when examining the structure of a basic controller, where the convenience of direct database operations can inadvertently lead to a lack of separation of concerns and an increase in code complexity. Fortunately, there is a good solution for that.

Continue reading “Laravel: Repository Pattern”

Laravel Temporary URLs & MinIO

I really like Laravel as framework, because it simplifies a lot of stuff – instead of focusing on every detail, we can just use a lot of tools and focus more or business logic. Of course, sometimes they are a bit limited, and we need to extend them or even replace, but overall, it is a very solid solution with amazing community support. The problem starts if something is not well documented or even documented in wrong way and in effect, we have some hidden functionalities. Last time I found something like that related to filesystems and MinIO driver, finally decided to write separate blog post about that, because it may help many people.

Continue reading “Laravel Temporary URLs & MinIO”

Kubernetes: liveness & readiness probes with Nginx and PHP-FPM

Last time I wrote about linking PHP-FPM and Nginx on Kubernetes (but also Docker). It is very common configuration because PHP is so popular as backend and Nginx offers great performance with low resources usage. If we use such mix, we should also think more about proper health check in our cluster. Without that, it is possible clients will “hit the wall” if some of services will stop work or when we will add some important hotfix during normal work. Fortunately, Kubernetes offers us build-in solution to quickly determine state of our pods and containers inside them. Thanks to this, we can periodically check state and decide if something requires attention or automatic actions from infrastructure level. Let’s check them in term of mentioned PHP and Nginx configuration.

Continue reading “Kubernetes: liveness & readiness probes with Nginx and PHP-FPM”

Kubernetes: Nginx and PHP-FPM

When we want to use PHP-FPM, in most cases, we also need to use some of the web servers. Typical choice is Nginx because it is a very light, reliable, and configurable solution which can handle even very big traffic without any issues. There are two methods of linking Nginx and PHP-FPM on the backend: TCP connections and UNIX sockets. In this post, I would like to share them in term of Kubernetes configuration. It can be applied also on standard Docker solutions without issues.

Continue reading “Kubernetes: Nginx and PHP-FPM”

Database migration – do not trust framework

In theory working with different databases is not a big problem, because framework can handle everything for you. In real world scenarios, there a lot of strange caveats. Last month’s my team works with huge and extraordinarily complex database migration. Process looked and something impossible, but “mission impossible” is exactly something for us. But of course, not challenge itself was the most important in this situation. Thanks to this migration we learned a lot and after we are much more cautious when we work with databases, especially when we use some backend frameworks.

Continue reading “Database migration – do not trust framework”