PHP code example of magewirephp / portman

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

    

magewirephp / portman example snippets


return [
    'directories' => [
        'source' => [
            'foo' => [
                'composer' => [ // if you want to download the sources from packagist
                    'name'   => 'example/package', // package name
                    'version'   => '^0.1.0', // the version constraint to download
                    'version-lock'   => '0.1.0', // a locked version (not  original source code lives
        'augmentation' => ['baz'], // directories with the code that overwrites the original classes
        'additional' => [], // directories with extra code that is just additional code to copy to the dist
        'output' => 'dist' // directories with extra code that is just additional code to copy to the dist
    ],
    'transformations' => [
        'Foo\\' => [
            'rename'          => 'Baz\\', // rename the Foo namespace to Baz
            'file-doc-block' => '/** Readme */', // add a doc-block to all the files in Foo
            'children'        => [
                'Bar' => [
                    'rename'            => 'Baz', // rename class Bar to Baz (with the namespace change it was Foo\Bar and becomes Baz\Baz)
                    'remove-methods'    => ['unnecessaryBazMethod'] // remove the method from the class,
                    'remove-properties' => ['unnecessaryProperty'] // remove the property from the class,
                ]
            ]
        ]
    ],
    'post-processors' => [
        'rector'       => false, // should run Rector after build/watch?
        'php-cs-fixer' => false, // should run PHP-CS-Fixer after build/watch?
    ]
];

return [
    'directories' => [
        'source' => [
            'foo' => [
                'glob'   => '**/*.php', // only php files
                'ignore' => [
                    'DontIncludeMe/**/*' // but nothing from 'DontIncludeMe'
                    '!DontIncludeMe/PleaseAddMe.php' // Except for the 'PleaseAddMe' file in 'DontIncludeMe'
                ]
            ],
            'bar' // the whole directory
        ], // directories where the original source code lives
        ...
    ],
    ...
];
text
foo
  ClassFoo.php
  Namespace
    ClassBar.php
  DontIncludeMe
    PleaseAddMe.php
    ClassBaz.php
    ClassRemoved.php