PHP code example of oguzcandemircan / laravel-stub-generator
1. Go to this page and download the library: Download oguzcandemircan/laravel-stub-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/ */
oguzcandemircan / laravel-stub-generator example snippets
return [
'source_path' => storage_path('stubs/source'), // stubs source path
'target_path' => storage_path('stubs/target'), // stubs target path
];
//storage/stubs/source/model.stub
namespace {{namespace}};
use Illuminate\Database\Eloquent\Model;
class {{modelName}} extends Model
{
protected $fillable = [{{fillable}}];
}
LaravelStubGenerator::source('model')->params([
'{{modelName}}' => 'UserModel',
'{{namespace}}' => 'App\Models',
'{{fillable}}' => "'name', 'email', 'age'",
])->generate();
LaravelStubGenerator::source('model')->params([
'{{modelName}}' => 'UserModel',
'{{namespace}}' => 'App\Models',
'{{fillable}}' => "'name', 'email', 'age'",
])->save('UserModel.php');
// force save
->save('UserModel.php', true);
//storage/stubs/target/UserModel.php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class UserModel extends Model
{
protected $fillable = ['name', 'email', 'age'];
}
LaravelStubGenerator::source('model')->params([
'{{modelName}}' => 'UserModel',
'{{namespace}}' => 'App\Models',
'{{fillable}}' => "'name', 'email', 'age'",
])->download('UserModel.php');