DocsDeveloper guideBuild an add-on
How add-ons work
An add-on is a folder under app/Addons/<Name> with an addon.php manifest. The system finds it on disk, and switches it on only when its own row says it is installed. Read this page first if you plan to extend OptiraPOS.
2 min read
Why add-ons never edit core files
A core update overwrites files by their path. An add-on that registered itself by editing routes/web.php, config/abilities.php or the menu file would be silently removed by the next update. So add-ons register at runtime: a provider merges each one's routes, rights, menus and assets into the loaded application. The files on disk stay as core shipped them (app/Providers/AddonServiceProvider.php:13-32).
When an add-on is live
An add-on is live only when its files are on disk AND it has an installed row, written after its migrations ran (app/Support/Addons/AddonManager.php:8-20). An add-on that is on disk but not installed mounts nothing (app/Support/Addons/AddonRoutes.php:20).
What happens at boot
For every installed add-on, AddonServiceProvider::bootOne does this, in order (app/Providers/AddonServiceProvider.php:109-261):
- Loads its migrations from
database/migrationsand, on the command line, its console commands (:118-128). - Registers its own service provider, if the manifest names one (
:130-134). - Mounts its
routes.phpinside thewebandauthmiddleware, so a page cannot be published without a sign-in by mistake (:136-162). - Merges its rights groups, record-rule models, URL segments, event listeners and model access into the running configuration (
:164-260).
Each add-on boots inside its own try/catch. One that throws is reported and left out, and the rest of the system keeps working (:62-71). Then the manifest hooks run, boot first and booted once the whole application is up (:73-76). Last, menus and asset URLs are shared with the pages (:78, :269-300).