PHP code example of shamaseen / laravel-files-generator

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

    

shamaseen / laravel-files-generator example snippets


php artisan generate:stub pathToStub.stub pathToOutput.extension --replace='key 1' --with='value 1' --replace="key 2" --with='value 2'

FilesGenerator::stub('PathToYourStubFile.extension')
        ->replace('string to be replaced','The replacement value')
        ->output('outputPath.extension');

php artisan generate:config 'pathToYourConfig/configFileName.php'

FilesGenerator::fromConfigFile('configPath.php');

php artisan ungenerate:config 'pathToYourConfig/configFileName.php'

FilesUngenerator::fromConfigFile('configPath.php');

php artisan vendor:publish --provider='Shamaseen\Generator\GeneratorServiceProvider'


return 
[
    [
        'stub' => 'first.stub',
        'output' => 'first.generated',
        'replace' => [
            '{% to be replaced 1 %}' => 'value',
            '{% to be replaced 2 %}' => 'value'
        ]
    ],
    [
        'stub' => 'second.stub',
        'output' => 'second.generated',
        'replace' => [
            '{% to be replaced 1 %}' => 'value',
        ]
    ]
];

php artisan generate:config 'pathToYourConfig/configFileName.php'