PHP code example of maxbeckers / php-builder-generator

1. Go to this page and download the library: Download maxbeckers/php-builder-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maxbeckers / php-builder-generator example snippets




namespace App\Model;

use MaxBeckers\PhpBuilderGenerator\Attributes\Builder;

#[Builder]
class User
{
    public function __construct(
        public string $name,
        public string $email,
        public ?int $age = null,
        public array $roles = []
    ) {}
}

$user = UserBuilder::builder()
    ->name('John Doe')
    ->email('[email protected]')
    ->age(30)
    ->roles(['admin'])
    ->build();
json
{
  "config": {
    "allow-plugins": {
      "maxbeckers/php-builder-generator": true
    }
  }
}
bash
./vendor/bin/php-builder-generator