Skip to content

forxer/blade-components-reflection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blade Components Reflection

Runtime reflection utilities for class-based Blade components. Given a component class, it reports the attributes a Blade tag can set on it:

  • AttributeReflector::settableProperties($class) — public, non-promoted, externally-settable properties (excludes static, promoted, private(set)/protected(set), and Illuminate\View\Component internals), kebab-cased.
  • AttributeReflector::constructorParameters($class) — every constructor parameter, with a required flag.

It is a small, provider-less library (no service provider, no config). Consumers that hydrate public properties from the Blade attribute bag at render time use it directly; the companion dev tool forxer/blade-components-ide-helper uses the same class to generate IDE metadata.

Installation

composer require forxer/blade-components-reflection

Usage

use Forxer\BladeComponentsReflection\AttributeReflector;

$properties = AttributeReflector::settableProperties(MyComponent::class);
// [['name' => 'variant', 'kebab' => 'variant', 'type' => 'string'], ...]

$parameters = AttributeReflector::constructorParameters(MyComponent::class);
// [['name' => 'label', 'kebab' => 'label', 'type' => 'string', 'required' => true], ...]

License

MIT

About

Runtime reflection utilities for class-based Blade components (settable attributes & constructor parameters).

Resources

License

Stars

Watchers

Forks

Contributors

Languages