PHP code example of eng-mohamedemad-dev / command-module-generator

1. Go to this page and download the library: Download eng-mohamedemad-dev/command-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/ */

    

eng-mohamedemad-dev / command-module-generator example snippets

 artisan make:module Car               # توليد موديل/خدمة/كنترولر... افتراضي web

php artisan make:module Invoice --type=api --repo   # توليد كل شيء كموديول API+ توليد repository

---php artisan make:module Ticket --path=admin/tickets # وضع الواجهات بمجلد معين

php artisan make:module Post --no-policy   # يعطّل توليد البوليصي فقط

## ⚙️ Optionsphp artisan make:module City --requests-mode=single # يولد ملف request واحد فقط



| Option | Description |php artisan delete:module Car     # يحذف كل ملفات موديول Car (كل ما تم توليده)

|--------|-------------|

// Controller → Service → Model/Repository
class CarController extends Controller
{
    public function __construct(private CarService $service) {}

    public function index(Request $request)
    {
        $data = $this->service->list(15);
        return CarResource::collection($data);
    }
}

public function register(): void
{
    $this->app->bind(\App\Interfaces\CarInterface::class, \App\Services\CarService::class);
    $this->app->bind(\App\Interfaces\CarRepositoryInterface::class, \App\Repositories\CarRepository::class);
}

use Illuminate\Database\Eloquent\Attributes\UsePolicy;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;

#[UsePolicy(CarPolicy::class)]
#[ObservedBy([CarObserver::class])]
class Car extends Model
{
    //
}
bash

php artisan make:module Car --type=web---

php artisan make:module Brand --type=web --path=admin/brand

bash  - `default_views_path`: مسار الواجهات للويب (افتراضي resources/views/{module})

php artisan make:module Invoice --type=api  - `make_repo`: توليد ريبوزيتوري؟

php artisan make:module Product --type=api --repo  - `make_resource`, `make_policy`, `make_observer`: فعّل/عطّل أي نوع


resources/views/
└── car/
    ├── index.blade.php
    ├── create.blade.php
    ├── edit.blade.php
    └── show.blade.php

routes/
└── web.php                              # Auto-registered Route::resource
bash
php artisan make:module Category --type=web --path=admin/categories