php-builder-generator

PHP Builder Generator Documentation

Welcome to the PHP Builder Generator documentation! This library automatically generates builder patterns for your PHP classes — as a dev-only dependency.

What is PHP Builder Generator?

PHP Builder Generator is a Composer plugin that creates builder classes for your PHP objects at build time. Configuration lives in a single php-builder-generator.php file in your project root — your production classes stay completely clean, with no dependency on this library.

Key Benefits

Quick Example

// php-builder-generator.php
use MaxBeckers\PhpBuilderGenerator\Config\PhpBuilderGeneratorConfig;

return PhpBuilderGeneratorConfig::configure()
    ->scanDirectory('src/Model');
// src/Model/User.php — no imports from this library!
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();

Documentation Sections

Getting Started

Features & Configuration

Examples

Contributing

Requirements

Support


Ready to get started? Check out the Quick Start Guide!