Upgrading to 3.0
Version 3.0 introduces a plugin-based architecture for module auto-discovery, replacing the monolithic service provider with focused, composable plugin classes.Requirements
| Requirement | Version 2.x | Version 3.0 |
|---|---|---|
| PHP | 8.0+ | 8.3+ |
| Laravel | 9, 10, 11 | 11+ |
Breaking Changes
Removed Features
ModularEventServiceProvider
Removed:
ModularEventServiceProviderReplacement: EventsPlugin (auto-registered)If you extended ModularEventServiceProvider, remove it from your code. Event discovery is now handled automatically by the EventsPlugin.ModuleRegistry::getCachePath()
Removed: After:
ModuleRegistry::getCachePath()Replacement: Cache::path()Before:Livewire Integration
Removed: The
make:livewire --module built-in supportReplacement: Install separate packagemodular-livewire package provides the same functionality as before.Cache Changes
| Aspect | Version 2.x | Version 3.0 |
|---|---|---|
| Cache file | bootstrap/cache/modules.php | bootstrap/cache/app-modules.php |
| Cache content | Module paths only | All plugin discovery data |
bootstrap/cache/modules.php file can be safely deleted.
New Architecture
Plugin System
Version 3.0 introduces a plugin-based architecture for better extensibility and separation of concerns. Core Classes:Built-in Plugins
All module functionality is now handled by specialized plugins:| Plugin | Responsibility |
|---|---|
ModulesPlugin | Discover composer.json, create ModuleConfig |
RoutesPlugin | Load route files |
ViewPlugin | Register view namespaces |
BladePlugin | Register Blade components |
TranslatorPlugin | Register translations |
EventsPlugin | Discover event listeners |
MigratorPlugin | Register migration paths |
GatePlugin | Register model policies |
ArtisanPlugin | Register commands |
PHP 8 Attributes
Plugins use attributes to control their lifecycle:| Attribute | Behavior |
|---|---|
#[AfterResolving(Service::class)] | Defer until service is resolved |
#[OnBoot] | Execute during booting() hook |
| (none) | Explicit call via PluginHandler::handle() |
Migration Steps
Check Requirements
Ensure your environment meets the new requirements:If you’re on older versions:
- For Laravel 9/10: Stay on Modular 2.x
- For PHP 8.0-8.2: Stay on Modular 2.x
Update Composer
Update the package:If you get dependency conflicts, you may need to upgrade Laravel first:
Update Code References
Search your codebase for removed classes and update them:AutoDiscoveryHelper → FinderFactory:ModularEventServiceProvider:ModuleRegistry::getCachePath():
Test Your Application
Run your test suite to ensure everything works:Pay special attention to:
- Event listeners
- Module discovery
- Custom discovery code
New Features in 3.0
Laravel Optimize Integration
Modular now integrates with Laravel’s optimize commands:Custom Plugins
You can now create custom plugins to extend module discovery:- Must extend
InterNACHI\Modular\Plugins\Plugin - Are automatically integrated into caching
- Can use lifecycle attributes
- Share the unified cache with built-in plugins
Auto-Aliasing in Tinker
Modular now supports auto-aliasing module classes in Tinker sessions, making it easier to work with module classes interactively.Upgrading to 2.0
Version 2.0 dropped support for older versions of PHP and Laravel.Requirements
| Requirement | Version 1.x | Version 2.0 |
|---|---|---|
| PHP | 7.3+ | 8.0+ |
| Laravel | 7, 8, 9, 10 | 9, 10, 11 |
Breaking Changes
If you’re using PHP 7 or Laravel 7/8, you must stay on the 1.x releases.Migration Steps
Version History
Version 2.2.0 (2024-04-05)
Added:- PhpStorm exclude path support in
modules:synccommand - Prevents double-registration of modules in IDE
Version 2.1.0 (2024-03-18)
Added:- Laravel 11 support
- Event discovery support
- Error with module command signatures
Version 2.0.0 (2023-05-19)
Changed:- Dropped support for PHP 7.x
- Dropped support for Laravel 7 and 8
Version 1.12.0 (2023-05-19)
Added:- Factory model name resolution inside modules
- Support for new
make:commandchanges in Laravel 10
Version 1.11.0 (2023-02-14)
Added:- Laravel 10 support
Version 1.10.0 (2022-08-12)
Fixed:- Improved path normalization on Windows
Version 1.9.0 (2022-07-06)
Fixed:make:migrationandmake:livewirenow properly load--moduleoption- Unknown module with
--moduleflag now triggers console error
- Additional tests for
make:commands
Version 1.8.0 (2022-06-04)
Added:- Blade component namespaces (e.g.,
<x-module::component />)
- Issue with
make:seedercommand in Laravel 9.6.0+
Version 1.7.0 (2022-02-11)
Added:- Laravel 9 support
Version 1.6.0
Added:- Custom module stubs support
- Only register
make:livewireintegration if Livewire is installed
Version 1.5.0
Added:- Livewire
make:livewirecommand support make:castcommand support- PhpStorm library roots syncing
Version 1.4.0
Added:--moduleflag support inphp artisan db:seed
- Seeders created in correct namespace (Laravel 8+)
- Factories created in correct namespace (Laravel 8+)
- Module namespace applied to models when creating factories
Version 1.3.0
Added:- Translation support in modules
- Switched to
diglactic/laravel-breadcrumbs
Version 1.2.0
Added:- Laravel 8 factory class auto-registration
- Better Windows support
- Composer 2.0 support
- Improved file scanning efficiency
Version 1.1.0
Added:make:componentcommand support- Component auto-discovery
- PhpStorm config file updates in
modules:sync - Partial
--allsupport formake:model
- Single
app-modules/*composer repository instead of per-module repositories - Moved tests from
autoload-devtoautoload
Version 1.0.0
Added:- Initial release
Staying Updated
To stay informed about new releases:- Watch the GitHub repository
- Check the CHANGELOG.md
- Follow @inxilpro on Twitter
Always review the changelog and test thoroughly in a development environment before upgrading production applications.