PHP code example of nahid-ferdous / laravel-module-generator

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

    

nahid-ferdous / laravel-module-generator example snippets


'stubs' => [
    'model' => 'model.stub',
    'controller' => 'controller.stub',
    'service' => 'service.stub',
    'repository' => 'repository.stub',
    'migration' => 'migration.stub',
    'request' => 'request.stub',
    'collection' => 'collection.stub',
    'resource' => 'resource.stub',
],



return [
    'base_path' => base_path('module'),
    'models_path' => base_path('module/models.yaml'),
    'stubs' => [
        'model' => 'model.stub',
        'controller' => 'controller.stub',
        'service' => 'service.stub',
        'repository' => 'repository.stub',
        'migration' => 'migration.stub',
        'request' => 'request.stub',
        'collection' => 'collection.stub',
        'resource' => 'resource.stub',
    ],
    // Postman collection settings
    'postman' => [
        'default_base_url' => '{{base-url}}',
        'default_prefix' => 'api/v1',
        'output_path' => 'module/postman_collection.json',
    ],
    // DB diagram settings
    'dbdiagram' => [
        'output_path' => 'module/dbdiagram.dbml',
    ],
];
bash
php artisan module-generator:install
bash
# Publish configuration file
php artisan vendor:publish --tag=module-generator-config

# Publish stub files for customization
php artisan vendor:publish --tag=module-generator-stubs
bash
php artisan module:generate --force                                    # Overwrite existing files
php artisan module:generate --file=custom/path/models.yaml            # Use custom YAML file
php artisan module:generate --skip-postman                            # Skip Postman collection generation
php artisan module:generate --skip-dbdiagram                          # Skip DB diagram generation
php artisan module:generate --skip-backup                             # Skip Code Backup generation
php artisan module:generate --postman-base-url=https://api.myapp.com  # Custom API base URL
php artisan module:generate --postman-prefix=api/v2                   # Custom API prefix
bash
php artisan postman:generate
php artisan postman:generate --file=custom/models.yaml
php artisan postman:generate --base-url=https://api.myapp.com --prefix=api/v1
bash
php artisan dbdiagram:generate
php artisan dbdiagram:generate --file=custom/models.yaml --output=custom/database.dbml
bash
# Generate with backup (default)
php artisan module:generate --file=models.yaml

# Generate without backup
php artisan module:generate --file=models.yaml --skip-backup

# List available backups
php artisan module:rollback --list

# Rollback to latest backup  
php artisan module:rollback

# Rollback to specific backup
php artisan module:rollback --backup=2025-01-15_14-30-22

# Clean up old backups
php artisan module:rollback --cleanup
bash
php artisan vendor:publish --tag=module-generator-stubs