PHP code example of respect / fluentgen

1. Go to this page and download the library: Download respect/fluentgen 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/ */

    

respect / fluentgen example snippets


$config = new Config(
    sourceDir: __DIR__ . '/src',
    sourceNamespace: 'App\\Formatters',
    outputDir: __DIR__ . '/src/Mixins',
    outputNamespace: 'App\\Formatters\\Mixins',
);

$scanner = new NamespaceScanner(
    nodeType: Formatter::class,
    excludedClassNames: ['FormatterBuilder'],
);

$generator = new MixinGenerator(
    config: $config,
    scanner: $scanner,
    methodBuilder: new MethodBuilder(classSuffix: 'Formatter'),
    interfaces: [
        new InterfaceConfig(
            suffix: 'Builder',
            returnType: Chain::class,
            static: true,
        ),
        new InterfaceConfig(
            suffix: 'Chain',
            returnType: Chain::class,
            rootExtends: [Formatter::class],
        ),
    ],
);

$files = $generator->generate();

foreach ($files as $filename => $content) {
    file_put_contents($filename, $content);
}