How megabre/megaforbb works
Purpose and entry points
MegaforBB is a PHP 8+ community-forum platform: forums, topics/posts, articles, private messages, moderation, portal content, documentation, and an idea-voting module. HTTP enters through public/index.php, bootstraps the Forecor kernel, then dispatches route handlers from Route/web.php, Route/admin.php, Route/api.php, and module route files. Scheduled work enters through public/cron.php.
Kernel, request lifecycle, and rendering
Forecor is the application boundary between HTTP and app code. It supplies application bootstrap, routing, sessions, security headers, dependency injection, and event dispatch; controllers form the presentation/API boundary and use services/models underneath.
• Forecor/Core/Application.php
• Forecor/Core/Router.php
• Forecor/Core/SecurityHeaders.php
• App/Controllers/BaseController.php
• App/Core/TemplateEngine.php
Responses are primarily Twig-rendered, theme-selected frontend/admin pages, with distinct API controllers for programmatic responses. Theme assets and templates are deployable customization surfaces.
• App/Controllers/ApiController.php
• Inc/Template/frontend/default/views/base.html.twig
• Inc/Template/admin/default/views/base.html.twig
Core forum domain
The principal write/read flow is controller → request validation/service logic → Eloquent models → rendered forum/topic pages. The core graph centers on User, forum hierarchy (Category, Forum), Topic, and Post; auxiliary models support tags, polls, attachments, reads, subscriptions, reactions, reports, and moderation.
• App/Controllers/ForumController.php
• App/Controllers/TopicController.php
• App/Services/TopicService.php
• App/Models/Topic.php
• App/Models/Post.php
Authentication, profiles, authorization, private messaging, notifications, and user preferences cross-cut that flow. Permissions are implemented as roles/definitions/content permissions and a reusable permission trait.
• App/Controllers/AuthController.php
• App/Services/AuthService.php
• App/Models/Role.php
• App/Traits/HasPermissions.php
Persistence and background processing
Eloquent targets MySQL/MariaDB. The repository includes a baseline schema and chronological migrations; release installs may import the prepared schema, while upgrades use the migration runner.
• App/Database/schema.sql
• App/Database/migrations/2025_01_01_000001_create_search_and_features_tables.php
• Forecor/bin/migrate.php
Cron executes recurring publication, RSS import, and version/security-related maintenance. Importers provide staged ingestion from XenForo, MyBB, and other MegaforBB installations, with ID mapping and counter synchronization.
• public/cron.php
• Forecor/cron/publish_scheduled_topics.php
• App/Services/Rss/RssFeedImportRunner.php
• App/Services/Import/MegaforBBImporter.php
Events, plugins, and modules
Domain events decouple topic/post/user actions from side effects: indexing, activity logs, user alerts, webhooks, and cache purges. Plugin loading extends this same application surface; plugin routes, listeners, templates, and lifecycle scripts live outside core app code.
• App/Events/TopicCreated.php
• App/Listeners/IndexTopicInMeilisearch.php
• App/Listeners/VarnishPurgeListener.php
• App/Services/PluginLoader.php
• Inc/Plugin/AiAutoReply/plugin.php
Idelist is a bounded feature module with its own controllers, models, services, provider, routes, votes, comments, and status workflow rather than being embedded in the forum domain.
• App/Modules/Idelist/Providers/IdealistServiceProvider.php
• App/Modules/Idelist/Services/IdeaStatusService.php
• Route/idelist.php
Infrastructure, external boundaries, and administration
Operational services abstract cache (file/Redis), Meilisearch, local/S3-compatible storage, Varnish purge, mail, Telegram-style webhooks, captcha, Stop Forum Spam, and RSS HTTP fetches. Security includes rate/attack presets, audit logging, censorship, file verification, and admin 2FA.
• App/Services/Cache.php
• App/Services/MeilisearchService.php
• App/Services/StorageService.php
• App/Services/SecurityService.php
• App/Config/SecurityAttackPresets.php
The /admin route area is the control plane for content, users, roles, themes, plugins, imports, backups, security, and operational settings; it is intentionally separated into many specialized controllers.
• App/Controllers/AdminController.php
• App/Controllers/AdminSecurityController.php
• App/Controllers/AdminImportController.php
• App/Controllers/AdminPluginsController.php
Main entry points: Router.php Route dispatch · BaseController.php Application controllers · AdminController.php Admin control plane · Application.php Forecor kernel
Components 20
Entry & Kernel
- HTTP entry
public/index.php - Forecor kernel · Bootstraps routing, DI, sessions, security headers, and events.
Forecor/Core/Application.php - Route dispatch · Dispatches web, admin, API, and module routes.
Forecor/Core/Router.php
Forum Application
- Application controllers · Forum, topic, auth, and API controllers handle requests.
App/Controllers/BaseController.php - Twig themes · Frontend and admin templates are deployable customization surfaces.
Inc/Template/frontend/default/views/base.html.twig - Topic service · Validates and coordinates core topic operations.
App/Services/TopicService.php - Forum domain models · User, category, forum, topic, and post form the core domain.
App/Models/Topic.php - Auth & permissions · Authentication, roles, profiles, and content permissions.
App/Services/AuthService.php
Events & Extensions
- Domain events · Decouples topic, post, and user side effects.
App/Events/TopicCreated.php - Side-effect listeners · Indexes content, logs activity, alerts users, purges caches, and sends webhooks.
App/Listeners/IndexTopicInMeilisearch.php - Plugin system · Loads plugin routes, listeners, templates, and lifecycle code.
App/Services/PluginLoader.php - Idelist module · Own provider, routes, idea workflow, votes, and comments.
App/Modules/Idelist/Providers/IdealistServiceProvider.php
Operations & Infrastructure
- MySQL / MariaDB · Eloquent persistence for forum and module data.
App/Database/schema.sql - Cron entry
public/cron.php - Scheduled jobs · Publishes scheduled topics, imports RSS, and performs maintenance.
Forecor/cron/publish_scheduled_topics.php - Import pipeline · Imports external forums with ID mapping and counter synchronization.
App/Services/Import/MegaforBBImporter.php - Migration runner · Applies chronological database upgrades.
Forecor/bin/migrate.php - Infrastructure services · Cache, search, storage, Varnish, mail, webhooks, captcha, and RSS HTTP.
App/Services/MeilisearchService.php - Security services · Rate protection, audit logging, censorship, file verification, and admin 2FA.
App/Services/SecurityService.php
Administration
- Admin control plane · Manages content, users, roles, themes, plugins, imports, security, and settings.
App/Controllers/AdminController.php
Connections 24
- HTTP entry → Forecor kernel: bootstraps
- Forecor kernel → Route dispatch: configures
- Route dispatch → Application controllers: web / API routes
- Route dispatch → Admin control plane: /admin routes
- Route dispatch → Idelist module: module routes
- Application controllers → Topic service: topic operations
- Application controllers → Auth & permissions: identity checks
- Application controllers → Twig themes: renders pages
- Topic service → Forum domain models: reads / writes
- Auth & permissions → Forum domain models: users and roles
- Forum domain models → MySQL / MariaDB: Eloquent persistence
- Forecor kernel → Domain events: dispatches
- Domain events → Side-effect listeners: triggers
- Side-effect listeners → Infrastructure services: search, cache, webhooks
- Plugin system → Forecor kernel: extends application
- Idelist module → MySQL / MariaDB: persists ideas
- Cron entry → Scheduled jobs: executes
- Scheduled jobs → Import pipeline: RSS / import work
- Import pipeline → MySQL / MariaDB: imports data
- Migration runner → MySQL / MariaDB: upgrades schema
- Admin control plane → Import pipeline: admin imports
- Admin control plane → Plugin system: manages
- Admin control plane → Security services: security controls
- Security services → Infrastructure services: protects integrations