| Install | |
|---|---|
composer require joshlogic/hotswap |
|
| PHP: | >=8.1 |
Hotswap is a Laravel package that enables modular development by generating self-contained packages with their own routes, migrations, service providers, and frontend scaffolding. It’s designed to make building reusable Laravel + Inertia + Vite modules simple and fast.
Install the package via Packagist
composer require joshlogic/hotswap:dev-main
Publish the core scaffolding:
php artisan hotswap:scaffold
Create a new module (e.g., ecommerce):
php artisan hotswap:create ecommerce
Rebuild autoload files:
composer dump-autoload
Compile frontend assets:
npm run build
Run the development server:
php artisan serve
Easily generate models, controllers, and migrations within a specific module (e.g., ecommerce) using the following commands:
Create a Model (with Migration & Controller)
php artisan hotswap:model ecommerce Product -mcr
Create a Controller
php artisan hotswap:controller ecommerce Product
Create a Model
php artisan hotswap:model ecommerce Product
Create a Migration
php artisan hotswap:migration ecommerce products
⚠️ As a safety precaution run:
composer dump-autoload
Manage your modules with the following commands:
Temporarily disable a module so it cannot be accessed by users (e.g., ecommerce):
php artisan hotswap:pause ecommerce
Re-enable a previously paused module:
php artisan hotswap:play ecommerce
Permanently delete a module:
php artisan hotswap:remove ecommerce
⚠️ As a safety precaution run:
composer dump-autoload
Export images from hotswap module to the root public folder:
php artisan vendor:publish --tag=public --force
Modular routes
Independent migrations & seeders
Built-in React (Inertia.js) page scaffolding
Automatic Vite config updates
Service provider registration
Hotswap is open-source software licensed under the MIT license.