mrickyansyah / laravel-command-generator

simplify to use laravel command with .stub file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Laravel Command Generator

To make it easier to make commands in laravel and can already be used with .stub files.

Laravel artisan documentation

How to use

  1. Paste file CommandGenerator.php to App\Console\Commands.
  2. Replace CommandGenerator class to YourClass.
  3. Rename the file accordingly.
  4. if your command interact with file .stub create file stub in App\Console\stubs.
  5. Edit property in file CommandGenerator.php.

Example code

/**
 * The name and signature of the console command.
 *
 * @var string
 */
protected $signature = 'make:enum {name}'; // {name} don't change it
/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Create spatie enum';

app/Console/stubs/create-enum.stub

/**
 * the stub file path
 * 
 * @var string
 */
protected $stubFile = 'create-enum';

app/Console/stubs/create-enum.stub

/**
 * the stub file path
 * 
 * @var string
 */
protected $stubFile = 'create-enum';
/**
 * the class namespace
 * 
 * @var string
 */
protected $namespace = 'App\\Enums';
/**
 * the path of generate file
 * 
 * @var string
 */
protected $pathGenerateFile = 'app/Enums';

About

simplify to use laravel command with .stub file


Languages

Language:PHP 100.0%