Certainly! You're hitting a stack overflow (infinite recursion) due to something in the service provider registration when both nwidart/laravel-modules and opgginc/codezero-laravel-localized-routes are installed in Laravel 13. This kind of issue usually results from the packages resolving or registering the same core Laravel service (translator) in a recursive manner.
This is a compatibility issue between the packages, likely related to the way they interact with the Laravel application's service container.
Steps to Troubleshoot and Solve
1. Check Provider Registration Order
Sometimes the order in which you register service providers in config/app.php (or in modules.php for nwidart packages) can lead to such recursion. Try switching the order:
'providers' => [
// ...
CodeZero\LocalizedRoutes\LocalizedRoutesServiceProvider::class,
Nwidart\Modules\LaravelModulesServiceProvider::class,
// ...
],
and then swap them:
'providers' => [
// ...
Nwidart\Modules\LaravelModulesServiceProvider::class,
CodeZero\LocalizedRoutes\LocalizedRoutesServiceProvider::class,
// ...
],
Run composer dump-autoload and see if the error persists after each change.
2. Use Latest Versions
Ensure both packages are fully up to date and tagged as compatible with Laravel 13. Both are heavily version-dependent for how they hook into the container and bootstrapping process.
composer require nwidart/laravel-modules opgginc/codezero-laravel-localized-routes
If any have beta versions or master/main branches, try those as well to see if the fix is upstream.
3. See if Localized Routes Loads Modules Twice
codezero-laravel-localized-routes (or its dependencies) may try to register routes by iterating all web routes, which, when combined with "modules" (which also have their own route files), can create cyclic or duplicated service resolution.
Check your AppServiceProvider or the providers for those two packages for any code like this:
public function boot()
{
$this->loadRoutesFrom(...);
}
Or middleware that sets the locale and attempts to resolve the translator multiple times. See if you can disable route or locale loading for one of the providers temporarily.
4. Workaround: Register Only One At A Time, Then Setup Manually
As a workaround, disable (comment out) one provider, run composer dump-autoload, publish package configs, then enable the other, and dump-autoload again. Then manually merge and load localized routes as needed in your own route files, instead of letting the providers auto-discover them.
5. Report the Compatibility Issue
If you confirm the error is only when both are installed—report the bug on both packages' issue trackers. Include your exact composer.json, Laravel version, and the call stack you shared above.
6. Example: Register Only One Provider
If you just want to get rid of the error to move on, you can register only one of the two providers, and manually merge their features. For example, for opgginc/codezero-laravel-localized-routes, after registering modules, add this to routes/web.php:
use CodeZero\LocalizedRoutes\Facades\LocalizedRoutes;
LocalizedRoutes::group(function () {
// Include your modular routes here
require base_path('Modules/Blog/Routes/web.php');
});
This way, you avoid the providers interacting recursively.
Summary
- Change providers order in
config/app.php. - Ensure latest versions of both packages.
- Check for duplicate locale/route registration in your code and the packages.
- Manual workaround: Avoid auto-discovery, register features manually.
- Report upstream with details if the above doesn't help.
Let me know if you need a more specific workaround or want help customizing the package registration!