Codementor Events

How and why I built Laravel Repository Package

Published Jul 21, 2021
How and why I built Laravel Repository Package

About me

I am a PHP developer since 2009. Building high-traffic websites and manage them with big DevOps infrastructure. I worked as CTO many tech companies and manage teams bigger than 20 developers.

The problem I wanted to solve

There is no embedded repository layer on laravel and need it on big projects.

What is Laravel Repository Package?

Created repository layer with cache adapter for Laravel and many other additions

Tech stack

PHP and Cache drives available on laravel like redis, memcache, dynamodb etc.

The process of building Laravel Repository Package

Firstly build repository layer for laravel skeleton and then build fractal presenters for stable responses for all your applications and then cache layer comes for package. Finally build criteriaInterface for get queries responses easily without coding, only using some parameters from url.

Challenges I faced

It's hard to set up multiple queries each request and cache each request's response on cache driver and expire them when needed or skipCache automatically. But the hardest side of the project listen eloquent events and remove caches when any model updated from outside of the relations.

Key learnings

Laravel skeleton, Illuminate/Cache layer, Illuminate/Request layer, laravel repository implematation and laravel stubs.

Tips and advice

When you start to build package try to split features multiple package for make your package flexible.

Final thoughts and next steps

Discover and read more posts from Burak Sormageç
get started
post commentsBe the first to share your opinion
Show more replies