Macroable – A Trait to Dynamically add Methods to a PHP Class

New package by the folks from Spatie:

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.

It works by leveraging the __call() magic function, and checking if any macro has been registered via the static macro method.

A trait to dynamically add methods to a class →
spatie/macroable (GitHub) →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.