nWidart / laravel-modules

Module Management In Laravel
https://docs.laravelmodules.com
MIT License
5.54k stars 962 forks source link

Issue on customizing config file #1779

Closed RealMrHex closed 7 months ago

RealMrHex commented 7 months ago

hey, i just set everything in the generator array of config file to false

'generator'  => [
            // app/
            'channels'        => ['path' => 'app/Broadcasting', 'generate' => false],
            'command'         => ['path' => 'app/Console', 'generate' => false],
            'emails'          => ['path' => 'app/Emails', 'generate' => false],
            'event'           => ['path' => 'app/Events', 'generate' => false],
            'jobs'            => ['path' => 'app/Jobs', 'generate' => false],
            'listener'        => ['path' => 'app/Listeners', 'generate' => false],
            'model'           => ['path' => 'app/Models', 'generate' => false],
            'notifications'   => ['path' => 'app/Notifications', 'generate' => false],
            'observer'        => ['path' => 'app/Observers', 'generate' => false],
            'policies'        => ['path' => 'app/Policies', 'generate' => false],
            'provider'        => ['path' => 'app/Providers', 'generate' => true],
            'repository'      => ['path' => 'app/Repositories', 'generate' => false],
            'resource'        => ['path' => 'app/Transformers', 'generate' => false],
            'rules'           => ['path' => 'app/Rules', 'generate' => false],
            'component-class' => ['path' => 'app/View/Components', 'generate' => false],

            // app/Http/
            'controller'      => ['path' => 'app/Http/Controllers', 'generate' => false],
            'filter'          => ['path' => 'app/Http/Middleware', 'generate' => false],
            'request'         => ['path' => 'app/Http/Requests', 'generate' => false],

            // config/
            'config'          => ['path' => 'config', 'generate' => false],

            // database/
            'migration'       => ['path' => 'database/migrations', 'generate' => false],
            'seeder'          => ['path' => 'database/seeders', 'generate' => false],
            'factory'         => ['path' => 'database/factories', 'generate' => false],

            // lang/
            'lang'            => ['path' => 'lang', 'generate' => false],

            // resource/
            'assets'          => ['path' => 'resources/assets', 'generate' => false],
            'views'           => ['path' => 'resources/views', 'generate' => false],
            'component-view'  => ['path' => 'resources/views/components', 'generate' => false],

            // routes/
            'routes'          => ['path' => 'routes', 'generate' => false],

            // tests/
            'test-unit'       => ['path' => 'tests/Unit', 'generate' => false],
            'test-feature'    => ['path' => 'tests/Feature', 'generate' => false],
        ],

then, created a module named Foo, here is the result:

image

looks like the config file is fully ignored.

also, i do not need the RouteServiceProvider in my modules, why there is nothing to customize it?

dcblogdev commented 7 months ago

nope it hasen't created the paths that have been turned off apart from when they exist in the stubs section:

'stubs' => [
    'enabled' => false,
    'path' => base_path('vendor/nwidart/laravel-modules/src/Commands/stubs'),
    'files' => [
        'routes/web' => 'routes/web.php',
        'routes/api' => 'routes/api.php',
        'views/index' => 'resources/views/index.blade.php',
        'views/master' => 'resources/views/layouts/master.blade.php',
        'scaffold/config' => 'config/config.php',
        'composer' => 'composer.json',
        'assets/js/app' => 'resources/assets/js/app.js',
        'assets/sass/app' => 'resources/assets/sass/app.scss',
        'vite' => 'vite.config.js',
        'package' => 'package.json',
    ],

If I comment out these:

'files' => [
            //'routes/web' => 'routes/web.php',
            //'routes/api' => 'routes/api.php',
            //'views/index' => 'resources/views/index.blade.php',
            //'views/master' => 'resources/views/layouts/master.blade.php',
            //'scaffold/config' => 'config/config.php',
            'composer' => 'composer.json',
            //'assets/js/app' => 'resources/assets/js/app.js',
            //'assets/sass/app' => 'resources/assets/sass/app.scss',
            //'vite' => 'vite.config.js',
            //'package' => 'package.json',
        ],

then generated will be:

Screenshot 2024-03-23 at 14 24 20

The RouteServiceProvider will be generated with the ModuleServiceProvider if you don't want the route you can delete the file and delete from the register method of the moduleserviceprovider

RealMrHex commented 7 months ago

@dcblogdev ok then, t.y.