Download the PHP package dotswan/modules-auto-discover without Composer
On this page you can find all versions of the php package dotswan/modules-auto-discover. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dotswan/modules-auto-discover
More information about dotswan/modules-auto-discover
Files in dotswan/modules-auto-discover
Package modules-auto-discover
Short Description Discover configs, translations, views, and .. automatically
License MIT
Homepage https://github.com/dotswan/modules-auto-discover
Informations about the package modules-auto-discover
Modules Auto-Discover
Automatically discover and register configurations, translations, and more from your nWidart/laravel-modules modules.
Table of Contents
- Introduction
- Installation
- Usage
- Auto-Discovery
- Disabling Auto-Discovery per Module
- Contributing
- License
- Support
Introduction
When using the nWidart/laravel-modules
package for modular Laravel applications, you might have noticed that configurations, translations, and other resources within your modules are not automatically discovered and registered by Laravel and you need to register/discover them in the ModuleServiceProvider
for every module. This package bridges that gap by automatically discovering and registering these resources, simplifying your module development process.
With Modules Auto-Discover, you no longer need to manually call methods like registerConfigs()
or registerTranslationss()
in your module service providers. The package handles the discovery and registration automatically during the application's boot process.
Installation
You can install the package via Composer:
The package uses Laravel's auto-discovery feature, so no additional steps are required to register the service provider.
Usage
Once installed, the package will automatically discover and register the following resources in your enabled modules:
- Configurations (
Config/
directory) - Translations (
Lang/
directory) - Views (
Resources/views/
directory) - Routes (
Routes/
directory) - Migrations (
Database/Migrations/
directory) - Factories (
Database/Factories/
directory) - Seeds (
Database/Seeders/
directory)
Auto-Discovery
By default, auto-discovery is enabled for all your modules. This means that any resources placed in the standard directories will be automatically registered without any additional configuration.
For example, placing a configuration file at Modules/YourModule/Config/permission.php
will make its contents available via Laravel's config()
helper:
Note: nWidart Modules
will create a config.php
file for every module by default (if you enabled to generate), we recommend you to create a separate file for each configuration to avoid conflicts (don't use config.php
for all modules)
Disabling Auto-Discovery per Module
If you want to disable auto-discovery for a specific module, you can do so by adding an "auto-discovery": false
entry to your module's module.json
file:
With auto-discovery
set to false
, the package will skip the automatic registration of resources for that module. You can then manually register resources in your module's service provider if needed.
To-Do
- [x] Discover
Config
- [x] Discover
Translations
- [ ] Discover
Views
- [ ] Discover
Routes
- [ ] Discover
Commands
Contributing
Contributions are welcome and encouraged! Please follow these steps to contribute:
- Fork the repository on GitHub.
-
Create a new branch for your feature or bug fix:
- Make your changes.
- Run
composer lint
to format your code with Pint rules. - Run
composer test
to run tests orcomposer test-coverage
to generate a coverage report. - Commit your changes with clear messages.
-
Push your branch to your forked repository:
- Open a pull request on the main repository.
Please make sure to write tests for your changes and ensure all existing tests pass.
License
The MIT License (MIT). Please see License File for more information.
Support
If you encounter any issues or have questions, please contact us via GitHub repository.