- What is Savannabits Modular and when should I use it in a Laravel project?
- Savannabits Modular is a Laravel package for modular application development. It lets you split your codebase into self-contained modules, each with its own routes, migrations, views, and service providers. It is most useful for large projects or domain-driven applications where a single flat app directory becomes hard to navigate and maintain. Smaller projects with a handful of controllers and models probably do not need the extra structure.
- How do I install savannabits/modular?
- Install it with Composer by running composer require savannabits/modular in the root of your Laravel application. After installation, check the package README for any required service provider registration or config publishing step, since Laravel versions before 5.5 do not support package auto-discovery. Composer will resolve the correct version for your Laravel release based on the package's own constraints.
- What files can a module contain?
- A module is a self-contained directory that can hold its own routes, migrations, views, and service providers. That means controllers, models, config, and other supporting classes can live inside the module namespace rather than the main app directory. The goal is to keep everything a feature needs in one place so it can be developed, tested, and even removed independently.
- How are module service providers registered with Laravel?
- Each module has its own service provider, which is how its bindings, routes, views, and other bootstrapping get loaded into the application. The package handles wiring those module providers into the framework so you do not have to manually list them in config/app.php. Refer to the package documentation for the exact convention used for naming and discovering module providers.
- How do module routes get loaded?
- Modules can define their own route files, such as separate web and API routes, and the module's service provider loads them during boot. This keeps route definitions next to the controllers and middleware they belong to instead of in one growing routes/web.php file. Route prefixes, middleware, and namespaces can then be applied per module, which helps avoid naming collisions between modules.
- Do module migrations run when I execute php artisan migrate?
- Module migrations are a core feature, so each module can ship its own database changes alongside the code that depends on them. The package registers those migration paths so they are picked up by the normal Artisan migrate command. For rollbacks and fresh rebuilds, test php artisan migrate:fresh and migrate:rollback in a local environment first to confirm all module paths are registered correctly.
- Which Laravel versions does Savannabits Modular support?
- Support depends on the version constraint declared in the package's composer.json, which you can review on Packagist or in the GitHub repository. Always check that constraint against your application's Laravel version before adding the dependency, especially if you are on an older or brand-new Laravel release. If your version is not listed, Composer will refuse the install rather than silently breaking your app.
- Can I write tests for individual modules?
- Yes, each module is a self-contained unit, so you can place feature and unit tests inside the module and run them with your normal PHPUnit or Pest setup. You may need to add the module's test directory to your phpunit.xml test suites or configure the module namespace in your autoload-dev section. Testing modules in isolation is one of the main advantages of this structure, since a module's tests travel with its code.
- How does Savannabits Modular compare to nwidart/laravel-modules?
- Both packages solve the same problem: breaking a Laravel application into modules with their own routes, migrations, views, and providers. nwidart/laravel-modules is the more widely adopted option with a larger ecosystem of generators and community modules, while Savannabits Modular is a lighter, Laravel-first take on the same idea. The right choice depends on whether you want heavy scaffolding tooling or a simpler structure you control yourself, so review both repositories' READMEs and issue activity before committing.
- Is Savannabits Modular suitable for production, and what should I watch out for?
- It is a plain Composer package, so deployment follows your normal workflow: run composer install --no-dev --optimize-autoloader, then cache routes, config, and views. Because modules add extra autoload and provider paths, make sure your production autoloader is regenerated during deploy so new module classes are discoverable. Before adopting it, check the repository's recent commit activity and open issues to confirm it is actively maintained against your Laravel version, and run your full test suite against a staging environment first.