Query scopes, meet action scopes

Link – timacdonald.me

Tim MacDonald shares an interesting technique.

Action scopes are...well...just query scopes really, but instead of filtering they take an action. It's just a random name I've given them to differentiate them from regular filtering based query scopes in my projects.

Read more [timacdonald.me]

Stay up to date with all things Laravel, PHP, and JavaScript.

Follow me on Twitter. I regularly tweet out programming tips, and what I myself have learned in ongoing projects.

Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

The mixin PHP DocBlock

Original – by Freek Van der Herten – 5 minute read

When using PHP, you've probably used DocBlocks. They can be used to add additional information that can't be inferred by looking at the source code alone. DocBlocks can be used by IDEs, like PhpStorm, to improve autocomplete suggestions.

In this blogpost, I'd like to highlight a not so well known DocBlock: mixin.

Read more

A Micro-Manager’s Guide to Chilling Out

Link – forge.medium.com

Don't try to manage your colleagues too much.

Employees want to be managed by people who empower them, not manage every bit of their day. The better you get at hitting the right balance between oversight and autonomy, the more likely you are to win long-term fans who will advocate for you as your career progresses.

Read more [forge.medium.com]

Making sense of API response times

Link – www.codemonkey.io

Mathias Hansen shares how API response time data is used at Geocodio and how to work with this kind of data in MySQL.

The API is the backbone of our business, so over the years we have continously worked to improve and ensure consistent performance. We look at many parameters such as uptime and error rates, but one of the key metrics is API response time. This is how we use this data.

Read more [www.codemonkey.io]

Client Side PHP

Link – atymic.dev

Atymic (real name unknown to me), a developer hailing from Sydnex, wrote a blogpost on how he managed to get PHP running in the browser via WebAssembly.

I'm sure you've come across plenty of sites that use javascript on the front end, but what about using PHP as a client side language? How, you ask? Since PHP is C based, it's actually possible to compile a version that's able to run inside your web browser using web assembly.

Read more [atymic.dev]

Testing your Laravel app using GitHub actions

Link – ma.ttias.be

Mattias Geniar explains how you can use GitHub actions to run the testsuite of your Laravel app.

Last year we wrote a blogpost about our setup we use for Oh Dear! with Gitlab, and how we use their pipelines for running our CI tests. Since then, we've moved back to Github since they introduced their free private repositories. In this post I'll describe how we re-configured our CI environment using Github Actions.

Read more [ma.ttias.be]

A package that adds resource links to your Laravel API resources

Original – by Freek Van der Herten – 3 minute read

At Spatie we have several projects where the UI is rendered using JavaScript (we're big fans of Inertia). The backend and routes are defined in the Laravel app. The backend sends information to the frontend using API resources.

We often add the available routes the frontend can use as links property on the resource. To avoid having to add all routes manually, my colleague Ruben released a package, called laravel-resource-links that can automatically add resource links to the API resource.

In this post, I'd like to introduce the package to you.

Read more