PHP code example of laravel-modules / module-generator
1. Go to this page and download the library: Download laravel-modules/module-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/ */
laravel-modules / module-generator example snippets
$generator = new \LaravelModules\ModuleGenerator\Generator;
$generator->publish(__DIR__.'/../stubs');
$generator->publish(
from: __DIR__.'/../stubs',
to: base_path('app')
);
namespace App\Console\Commands;
use Illuminate\Console\Command;
use LaravelModules\ModuleGenerator\Generator;
use function Laravel\Prompts\text;
class MakeCrudCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'make:crud {name?}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate a new CRUD';
/**
* Execute the console command.
*/
public function handle()
{
$name = $this->argument('name') ?? text('What is the CRUD name?');
$generator = new Generator;
$generator
->crud(name: $name)
->fromPath(base_path('stubs/crud'))
->toPath(base_path())
->appendToFile(
file: resource_path('js/components/SidebarItems.vue'),
content: file_get_contents(base_path('stubs/sidebar.stub')),
before: ' </ul>',
)
->publish();
$this->info('CRUD has been generated successfully.');
}
}