Welcome to the PHP Builder Generator documentation! This library helps you automatically generate builder patterns for your PHP classes using simple attributes.
PHP Builder Generator is a Composer plugin that automatically creates builder classes for your PHP objects. Instead of manually writing repetitive builder code, you simply add a #[Builder]
attribute to your class and the generator does the rest.
#[Builder]
class User
{
public function __construct(
public string $name,
public string $email,
public ?int $age = null
) {}
}
// Generated builder usage:
$user = UserBuilder::builder()
->name('John Doe')
->email('john@example.com')
->age(30)
->build();
Ready to get started? Check out the Quick Start Guide!