PHP code example of lukeraymonddowning / stubble

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

    

lukeraymonddowning / stubble example snippets


// class.php.stub



class {{ class }} extends Component {

    public function render() {
        return view('{{ view }}');
    }

}

// class.php.stub



class {{ class | pascal }} extends Component {

    public function render() {
        return view('{{ class | kebab }}');
    }

}

public function handle() {
    Stubble::publish('path/to/your/stub.php', app_path('Some/Directory/File.php'), ['class' => $this->argument('name')]);
}

// class: Some\Deeply\Nested\Thing
class {{ class | basename }} {} // class Thing {}

// class: Some/Class/With/Forward/Slashes
use {{ class | classname }} // Some\Class\With\Forward\Slashes

// view: some-nested.view
use {{ view | classname }} // SomeNested\View

// class: Some\ProjectClass

return view('{{ class | view }}'); // some.project-class

// .stub
Welcome to the {{ jungle | upper | plural }}! // Welcome to the JUNGLES!

// ServiceProvider
Modifier::macro('vowelless', function ($content) {
    return Str::of($content)->remove(['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'])->__toString();
});

// .stub
Hello {{ example | vowelless }} // All vowels will be removed from the value of 'example'

$content = Stubble::file('path/to/your/stub.php.stub', ['key' => 'value']);

$filename = (new Stubble)->replace("path/to/your/{{ file | kebab }}.php", ['file' => $this->argument('name')]);

Stubble::publish(
    'path/to/stub.php',
    'Path/To/Your/{{ class | basename }}.php',
    ['class' => $this->argument('class')]
);

Stubble::defineTags('--', '--'); // Use -- as the tag locators
Stubble::defineTags('{{', '--'); // Use {{ as the starting locator and -- as the ending locator
bash
php artisan make:magic MyDesiredClassName