Download the PHP package maximaster/attributemplate without Composer
On this page you can find all versions of the php package maximaster/attributemplate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maximaster/attributemplate
More information about maximaster/attributemplate
Files in maximaster/attributemplate
Package attributemplate
Short Description Create dynamic templates for your classes using attributes.
License MIT
Informations about the package attributemplate
maximaster/attributemplate
This library generates new classes from templates by resolving attributes into executable logic. Ideal for scenarios like creating database migrations from templates, configuration generation, etc.
Features
1. Attribute-Driven Template Customization
Define templates using PHP attributes to dynamically set class names, constants, and other properties:
2. Lazy Evaluation Providers
Use built-in providers to resolve values at runtime:
EvalString
: Execute PHP expressions (e.g.,new EvalString('uniqid()')
)Guid
: Generates UUIDsExpression
: Evaluate Symfony expressionsParam
: Inject values from context
Installation
Usage Example
Input Template
Generated Output
Available Attributes
@Rename
Dynamically rename the class:
@SetValue
Set constant/property values:
Quirks & Considerations
⚠️ Security Note: EvalString
executes arbitrary PHP code - only use trusted expressions.
⚠️ Requires PHP 8.3+ and Nette\PhpGenerator.
⚠️ Attributes can only be applied to:
- Classes
- Class constants
- Parameters
- Properties
Contributing
- test with
composer test
- lint with
composer lint
(also seecomposer fix
) composer qa
shortcuts bothtest
andlint
All versions of attributemplate with dependencies
maximaster/evalue Version ^1.0.0
nette/php-generator Version ^4.1@dev
nikic/php-parser Version ^5.4
maximaster/lazy-scalar Version ^1.0.0