To configure the module paths in the config file for `nwidart/laravel-modules`, you need to publish the package's configuration file and then set the `paths` key to specify the directories where your modules are located. Here are the steps:
1. Publish the Configuration:
- Run the following command to publish the package's configuration file:
bash
php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"
2. Edit the Configuration File:
- The configuration file will be published in the `config` directory. Open the `module.php` file and add the `paths` key to specify the directories where your modules are located. For example:
php
'paths' => [
'modules' => base_path('Modules/Core'),
],
3. Save and Refresh:
- Save the changes to the `module.php` file and then run `composer dump-autoload` to refresh the autoloading.
Example Configuration File:
php
<?php
return [
'namespace' => 'Modules',
'stubs' => base_path('Modules/Stubs'),
'paths' => [
'modules' => base_path('Modules/Core'),
],
'composer' => [
'merge-plugin' => [
'include' => ['Modules/*/composer.json'],
],
],
'cache' => true,
'register' => [
'Modules\Core',
],
];
Explanation:
- Namespace: Sets the default namespace for generated modules.- Stubs: Specifies the directory where the package's stubs are located.
- Paths: Specifies the directories where your modules are located.
- Composer: Configures the `composer.json` file to include the module files.
- Cache: Enables caching of module information.
- Register: Specifies which custom namespaces need to be registered by the package.
By following these steps, you can configure the module paths in the `nwidart/laravel-modules` package to manage your large Laravel application using modules effectively[1][2][3].
Citations:[1] https://nwidart.com/laravel-modules/v6/basic-usage/configuration
[2] https://github.com/nWidart/laravel-modules
[3] https://nwidart.com/laravel-modules/v1/introduction
[4] https://github.com/nWidart/laravel-modules/actions/runs/9539720431/job/26290392108
[5] https://laracasts.com/discuss/channels/laravel/nwidart-modules-laravel-issue-with-vite-config