PHP code example of b2r / composition

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

    

b2r / composition example snippets


use b2r\Component\Composition\Generator;

$gen = new Generator();
$gen->name('PDOWrapper')   # Set composition class|tarit name
    ->namespace('b2r\PDO') # Set namespace
    // ->asTrait()         # Output as trait
    ->target(PDO::class)   # Set composition target class
    ->property('pdo')      # set composition property name
    ->aliases([            # Define aliases
        'lastId' => 'lastInsertId',
        'begin'  => 'beginTransaction',
    ])
    ->excludes(['quote', 'query', 'exec']); # Exclude methods

echo $gen;
// $gen->save('PDOWrapper.php'); // Save to file