API Guide ​
Common use cases and patterns for developers.
Adding a New Module ​
- Create
modules/MyModule/withmodule.json - Add
Config/,Database/Migrations/,Entities/,Http/Controllers/,Repositories/,Routes/ - Enable via
modules_statuses.jsonorphp artisan module:enable MyModule - Run
php artisan modularous:buildto rebuild Vue assets if the module adds frontend pages
Adding a New Input Type ​
- Create component in
vue/src/js/components/inputs/(e.g.InputPrice.vue) - Register in app bootstrap or a plugin:
js
import { registerInputType } from '@/components/inputs/registry'
registerInputType('input-price', 'VInputPrice')- Use in schema:
{ myField: { type: 'input-price', ... } }
See Hydrates for full flow (PHP Hydrate + Vue component).
Repository Pattern ​
- All data access goes through repositories
- Use
$this->repositoryin controllers (from PanelController) - Lifecycle:
prepareFieldsBeforeCreate→create→beforeSave→prepareFieldsBeforeSave→save→afterSave - See Repositories for full lifecycle
Controller Flow ​
preload()— runs before index/create/edit; callsaddWiths(),setupFormSchema()setupFormSchema()— hydrates form inputs via InputHydratorindex()—addWiths(),addIndexWiths(),respondToIndexAjax()for AJAX, elsegetIndexData()→renderIndex()create()/edit()— load form schema, pass to view/Inertia
Finder ​
Finder::getModel($table)— resolve model class from table name (scans modules, then app/Models)Finder::getRouteModel($routeName)— resolve model from route name- Used by Module to resolve repository, model, controller
Route Generation ​
Use php artisan modularous:make:route to scaffold routes, migrations, controllers, repositories from module config. See make:route.
Currency Provider ​
When adding pricing without SystemPricing module:
- Implement
CurrencyProviderInterface - Register in config:
modularous.currency_provider= YourProvider::class - Or bind in a service provider:
$app->singleton(CurrencyProviderInterface::class, YourProvider::class)
Helpers (Frontend) ​
Prefer imports over window globals:
js
import { isObject, dataGet, isset } from '@/utils/helpers'Config Keys ​
modularous.services.*— service config (currency_exchange, etc.)modularous.roles— role definitionsmodularous.traits— entity traitsmodularous.paths— base paths