Posts tagged with trait

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

A trait to dynamically add methods to a class

by Freek Van der Herten – 4 minute read

We recently released our newest package called macroable. It contains a trait that, when applied to class, can dynamically add methods to that class. This trait is basically a stand alone version of the macroable trait in Laravel. In this post I'd like to show you how you can use it, how it works…

Read more

A trait to optionally abort a Laravel app

by Freek Van der Herten – 1 minute read

Inspired by Edd Man's post on optional value control-flows I made a small Laravel package to optionally abort your application. The package provides a Spatie\OrAbort\OrAbort-trait that can be used on any class you want. All the methods of the class will gain orAbort-variant. When the original…

Read more