PHP Ordrestyring v2 API Client Library

This one has been gathering dust in my private repositories for some time, so I decided to make it publicly available. It's a simple client library used to connect to Ordrestyring. I'm continously adding more supported endpoints, tests and methods as I find time or need them internally for our…

Advanced Route Model Binding in Laravel

So, imagine you have a platform on which each user has a list of Invoices, and those invoices have a number starting from 1000 for each user. You might still want to use URLs and endpoints like: /invoices/1005 instead of the primary key in the database. So, naively you…

Generating Initials from Names with PHP Initials Package

For a lot of projects, we use initials (Lasse Rafn = LR or LRA) to display employees and users. Repeating code over and over eventually felt wrong, so I packed the primary functionality into two different packages. Prepare yourself for some shameless self-promotion... okay, I do feel a bit shame. 1.…

Making Classes Iterable with ArrayAccess in PHP

I'm writing quite a lot API wrappers in PHP, and most GET index responses are paginated, so usually I return a PaginatedResponse class to the user of the wrapper, that has some different properties such as: items, page, totalPages and so on. However, for responses that are not paginated, I…

Faster Array Merging in PHP

I recently read a tweet (that I'm unable to find) stating that adding two arrays together is faster than using array_merge, so I decided to test it. I wrote a quick file that contains 3 for loops, each doing 10.000.000 iterations. Below are the benchmarks. Benchmarks Below…

Using Migrations to Modify Data in Production

The initial work on a project is always easier when it comes to the database and data therein. Things change a bit after going live, where a migration could potentially cause loss of data, or a migration would also require some data to be moved elsewhere or even modified. I've…

Speeding up Laravel in Simple Steps

Speeding up Laravel applications can be done fairly simple. This guide will only cover the absolute surface and won’t dig deep into specific applications. Using Cookie for Sessions Instead of Files Changing a config/environment variable can improve web-performance a bit. It’s very different depending on your site,…

Getting Started in Open Source - Contributing

I love Open Source, contributing to it especially. To me, it gives me a great feeling inside, seeing my changes or additions being merged, which is my primary reason for contributing. Getting started, however, is strangely hard. /Where do I start?/ /How do I know where to contribute? Will they…

Great Tech Podcasts and Blogs

Whenever I go for a walk with my dog, I tend to pull out my phone, and listen to different tech podcasts (Usually Five-Minute Geek Show with Matt Stauffer, link below). However I often find it difficult to find great podcast about stuff that I care about. The discovery-features in…