fyre/macro

A macro utility library.

Installs: 1 321

Dependents: 48

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/fyre/macro

v2.0 2025-09-24 11:48 UTC

This package is auto-updated.

Last update: 2025-09-24 11:49:57 UTC


README

FyreMacro is a free, open-source macro utility library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/macro

Macros

You can attach the Fyre\Utility\Traits\MacroTrait to any class.

use Fyre\Utility\Traits\MacroTrait;

// in any class
class MyClass {
    use MacroTrait;
}

Clear Macros

Clear all macros.

MyClass::clearMacros();

Has Macro

Determine whether a macro is registered.

  • $name is a string representing the name of the macro.
$hasMacro = MyClass::hasMacro($name);

Macro

Register a macro.

  • $name is a string representing the name of the macro.
  • $callback is the macro callback.
MyClass::macro($name, $callback);

Calling Macros

MyClass::macro('myMethod', function(): bool {
    return true;
});

new MyClass()->myMethod(); // true

Static Macros

You can attach the Fyre\Utility\Traits\StaticMacroTrait to any class.

use Fyre\Utility\Traits\StaticMacroTrait;

// in any class
class MyClass {
    use StaticMacroTrait;
}

Clear Static Macros

Clear all static macros.

MyClass::clearStaticMacros();

Has Static Macro

Determine whether a static macro is registered.

  • $name is a string representing the name of the macro.
$hasStaticMacro = MyClass::hasStaticMacro($name);

Static Macro

Register a static macro.

  • $name is a string representing the name of the macro.
  • $callback is the macro callback.
MyClass::staticMacro($name, $callback);

Calling Static Macros

MyClass::staticMacro('myMethod', function(): bool {
    return true;
});

MyClass::myMethod(); // true