PHP code example of emsifa / stuble

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

    

emsifa / stuble example snippets




namespace {? model_namespace["App\Models"] ?};

use Illuminate\Database\Eloquent\Model;

/**
 * Model {? entity ?}
 */
class {? entity.pascal ?} extends Model
{

    protected $table = "{? entity.snake.plural ?}";

}




namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Model product category
 */
class ProductCategory extends Model
{

    protected $table = "product_categories";

}


===
path = "app/Models/{? entity.pascal ?}.php"
===


namespace App\Models;

class {? entity.pascal ?} extends Model
{

    protected $table = "{? entity.snake.plural ?}";

}




$stuble->filter('substr', function (string $value, int $start, int $length = null) {
    return substr($value, $start, $length);
});


composer global 

===
[append]
file = "routes/web.php"
===
Route::resource('{? entity.kebab ?}', '{? entity.pascal ?}Controller');

===
[append]
file = "routes/web.php"
line = 15
===
Route::resource('{? entity.kebab ?}', '{? entity.pascal ?}Controller');

===
[append]
file = "routes/web.php"
after = "// Generated by Stuble"
===
Route::resource('{? entity.kebab ?}', '{? entity.pascal ?}Controller');

===
[append]
file = "routes/web.php"
before = "// Code aboves was generated by Stuble"
===
Route::resource('{? entity.kebab ?}', '{? entity.pascal ?}Controller');

// sample.stub

Your param: {? your_param ?}
Your param after substr: {? your_param.substr(0, 6) ?}