PHP code example of dakin / stubborn

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

    

dakin / stubborn example snippets



Stub::from('Support/Enums.php')
    ->name('Color')
    ->generate();
 >= 8.0



namespace {{ NAMESPACE }};

class {{ CLASS }}
{
    
}


use Dakin\Stubborn\Stub;

Stub::class;


Stub::from(__DIR__ . 'model.stub');


Stub::from(__DIR__ . 'model.stub')
    ->to(__DIR__ . '/App');


Stub::from(__DIR__ . 'model.stub')
    ->to(__DIR__ . '/App')
    ->name('new-model');


Stub::from(__DIR__ . 'model.stub')
    ->to(__DIR__ . '/App')
    ->name('new-model')
    ->ext('php');


Stub::from(__DIR__ . 'model.stub')
    ->to(__DIR__ . '/App')
    ->name('new-model')
    ->ext('php')
    ->replace('NAMESPACE', 'App');


Stub::from(__DIR__ . 'model.stub')
    ->to(__DIR__ . '/App')
    ->name('new-model')
    ->ext('php')
    ->replaces([
        'NAMESPACE' => 'App',
        'CLASS' => 'MyClass'
    ]);


Stub::from(__DIR__ . 'model.stub')
    ->to(__DIR__ . '/App')
    ->name('new-model')
    ->ext('php')
    ->replaces([
        'NAMESPACE' => 'App',
        'CLASS' => 'MyClass'
    ])
    ->generate();



namespace App;

class MyClass
{
    
}



namespace App;

class {{ NAME }}
{
    public function introduce(): string {
        return "I am a {{ NAME }}";
    }
}



namespace App;

class {{ NAME::studly }}
{
    public function introduce(): string {
        return "I am a {{ NAME::upper }}!";
    }
}


use Dakin\Stubborn\Stub;

Stub::modFunctions['repeat'] = fn ($theString) => $theString . $theString;


$stubber = Stub::from('path/to/my/stubs/the-actual.stub');


// During setup...
Stub::setStubFolder('path/to/my/stubs');

// Later on...
$stubber = Stub::from('the-actual.stub');


Stub::setContextFolder('path/to/my/src_folder')


$stubber = Stub::from('./stubs/the_actual.stub')
    ->to('./src/Support')
    ->name('NewClass')
    ->ext('php');


$stubber = Stub::from('the_actual.stub')
    ->to('Support')
    ->name('NewClass')
    ->ext('php');


$stubber = Stub::from('./stubs/Support/Enums.php')
    ->to('./src/Support/Enums')
    ->name('Color')
    ->ext('php');


$stubber = Stub::from('Support/Enums.php')
    ->name('Color');