PHP code example of kz370 / laravel-modular

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

    

kz370 / laravel-modular example snippets


// Enable/disable pattern auto-detection
'auto_detect_patterns' => true,

'filament' => [
    'enabled' => true,
    'layout' => 'nested',           // 'nested' or 'flat'
    'generate_form_schemas' => true,
    'generate_table_classes' => true,
    'subdirectories' => ['Pages', 'Schemas', 'Tables'],
    'default_icon' => 'heroicon-o-rectangle-stack',
],

'structure' => [
    'app/Models' => true,
    'app/Policies' => true,
    'app/Filament/Resources' => true,
    'database/migrations' => true,
    'database/seeders' => true,
    'lang' => true,
    // ... more options
],

// Add custom directories
'custom_directories' => [
    'app/Domain/ValueObjects' => true,
    'app/Domain/Enums' => true,
],

// Auto-detect from project, or specify manually
'locales' => null, // or ['en', 'ar', 'es']

'models' => [
    'use_translatable' => true,  // Spatie Translatable support
    'use_soft_deletes' => false,
    'use_uuids' => false,
],

'policies' => [
    'base_class' => 'App\\Policies\\BasePolicy', // or null
    'auto_register' => true,
],

   use Modules\Products\Providers\ProductsServiceProvider;

   public function panel(Panel $panel): Panel
   {
       return $panel
           // ... other config
           ->discoverResources(
               in: module_path('Products', 'app/Filament/Resources'),
               for: 'Modules\\Products\\Filament\\Resources'
           );
       
       // Or use the helper method:
       // ProductsServiceProvider::registerFilament($panel);
   }
   
bash
php artisan vendor:publish --tag=laravel-modular-config
bash
php artisan vendor:publish --tag=laravel-modular-stubs
bash
# Enable/disable modules
php artisan module:enable Products
php artisan module:disable Products

# Run migrations
php artisan module:migrate Products

# Generate components
php artisan module:make-model Product Products
php artisan module:make-controller ProductController Products