add module system#1304
Open
rbardtke wants to merge 4 commits into
Open
Conversation
rbardtke
requested review from
Geda173,
jackbayliss and
lanedirt
as code owners
March 20, 2026 23:11
…rovider::class) in ModulesController toggle() and index() to prevent arbitrary class instantiation - Tests: add 11 unit tests covering module discovery registry, slot rendering, multi-renderer concatenation, data passing, and slot isolation - Static state: add resetDiscovered() and resetSlots() methods to prevent test pollution - JS safety: move @moduleSlot(layout.resources_bar_js) to after }); closing so modules cannot silently break the JS object literal - Docs: clarify that auto-discovery is the primary installation path; manual config/modules.php entry is the fallback for packages without extra.laravel.providers - Style: fix 2 Pint issues in AppServiceProvider and ModuleSystemTest
Preview deploymentPreview environment for this PR is ready for functional testing. Use one of the test accounts below to log in.
Test accounts (click to expand)
This preview will be automatically destroyed when the PR is closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a modular extension system for OGameX, allowing features to be distributed as standalone Composer packages and installed on demand without modifying core files.
What was added:
ModuleServiceProvider(app/Modules/ModuleServiceProvider.php) — abstract base class all modules must extend. Handles automatic loading of routes, views, migrations, and translations from the package directory. Maintains a static discovery registry so the admin UI can list all installed modules regardless of how they were registered.ModuleSlotService(app/Services/ModuleSlotService.php) — allows modules to inject rendered HTML fragments into named slots in core Blade templates via a@moduleSlotdirective. Core views remain untouched; modules hook in declaratively.config/modules.php— opt-in list of module provider classes to activate. A module must be Composer-installed AND listed here (or auto-discovered) to be active.AppServiceProvider— updated to register providers fromconfig/modules.phpand skip any listed instorage/app/modules-disabled.json, which is readable before the DB boots./admin/modules) — lists all discovered modules with name, version, description, and enabled/disabled status. Supports toggling modules on/off at runtime without code changes.app/Contracts/Modules/) — interfaces for modules that extend core services:ProvidesGameObjects,ProvidesQueueProcessor,ProvidesHighscoreCategory,ExtendsPlanetService,ExtendsPlayerService.docs/modules.md) — full developer guide covering package structure, available contracts, the slot system, and the module manifest format.Showcase module:
ogamex/admin-panelis provided as a reference implementation — a standalone Composer package installable viacomposer require ogamex/admin-panelthat adds a dedicated admin panel at/admin-panel/. It is not bundled in this repo; it demonstrates the system works end-to-end with real Composer-based installation and auto-discovery.Type of Change:
Related Issues
Fixes #1303
Checklist
Before submitting this pull request, ensure all following requirements as outlined in CONTRIBUTING.md are met:
docs/modules.mdadded with full developer guide.Additional Information
Enable/disable without DB: Module state is stored in
storage/app/modules-disabled.json(plain file, no database). This is intentional — service providers are registered before Eloquent is available, so a DB-based registry would cause boot-order failures.Auto-discovery: Modules that declare their provider under
extra.laravel.providersin theircomposer.jsonare picked up by Laravel's standard package discovery. No manualconfig/modules.phpentry is required for Composer-installed modules; the admin UI will show them automatically.No breaking changes: All additions are additive. Existing core behaviour is unchanged. The
@moduleSlotcalls added tooverview/index.blade.phpandresources/index.blade.phprender nothing if no module has registered a handler for that slot.How to test the showcase module (ogamex/admin-panel)
The admin-panel module is a standalone Composer package hosted at https://github.com/rbardtke/admin-panel. Follow these steps to install and verify it:
1. Add the VCS repository and install the package:
2. Verify auto-discovery:
Navigate to
/admin/moduleswhile logged in as an admin. TheAdmin Panelmodule should appear in the list with statusEnabled.3. Verify the nav slot:
Open the classic admin panel at
/admin. The sidebar should show an Advanced Panel link injected by the module without any core template changes.4. Verify the dedicated panel:
Navigate to
/admin-panel/. You should see the standalone dark-themed admin dashboard showing universe stats (total players, planets, active fleets) and a universe config summary.5. Verify module pages:
/admin-panel/server-settings— edit and save a server setting, confirm it persists/admin-panel/rules— edit a rules tab, confirm it saves/admin-panel/developer-shortcuts— add units to a planet, confirm they appear in-game6. Test disable/enable:
On
/admin/modules, click Disable next to the Admin Panel module. Reload the page — theAdvanced Panellink should disappear from the admin sidebar and/admin-panel/should no longer be accessible. Click Enable to restore it.