flarum/statistics
A Flarum extension that provides forum statistics at a glance, helping administrators monitor activity and growth through key metrics such as discussions, posts, and registered users. Lightweight and easy to install, it adds a clear statistics overview to the admin dashboard.
Install through Composer and enable it like any Flarum extension:
composer require flarum/statistics
php flarum cache:clear
# then Admin → Extensions → Statistics → Enable
There are no migrations to run — the extension reads existing users, discussions, and posts tables rather than storing its own data, so enabling/disabling is non-destructive.
Where to look first
extend.php — shows the /api/statistics route and the DashboardPage extender that mounts the widget.js/src/admin/ — the widget component and its chart rendering.src/Api/Controller/ — the controller that aggregates counts and time-series data.First use case: log into the admin panel, open Dashboard, and confirm the Statistics widget renders totals plus the growth chart. Then call the API with an admin session/token to confirm you can consume it programmatically:
curl -H "Authorization: Token <admin-token>" https://forum.test/api/statistics
That endpoint is the real integration surface — the widget is just a consumer of it.
Dashboard-first monitoring. The default pattern is simply enabling the widget and letting admins eyeball user/discussion/post growth. Treat the Dashboard page as the "home" for community health.
External status boards. Because the data is exposed at /api/statistics, poll it from a cron job or uptime/status tool (Grafana JSON datasource, a small Laravel/PHP collector, etc.) using an admin token. This is the most common day-to-day leverage — get the numbers out of Flarum and into whatever you already monitor.
Snapshot for history. The extension computes aggregates live; it does not keep historical rows. If you need long-term reporting, write a scheduled command in your own extension that hits the endpoint (or queries the DB directly) and persists one row per day into a statistics_snapshots table. You then own retention, backfills, and charting.
Custom admin widgets via extenders. To add your own metrics card alongside it, create a small extension and use Flarum's DashboardPage extender to register another widget component. Mirror the structure of this extension's frontend component — same extend() registration, same widget position API. You can also use the extender to remove or reorder the Statistics widget without forking.
Overriding presentation. Need a different chart library or extra series? Don't patch vendor/; create an extension that imports the widget and uses Flarum's JS override() to replace its source/view, or register a replacement component and hide the original via the Dashboard extender.
Reporting commands. For periodic reports (weekly growth email, Slack digest), reuse the same aggregation queries inside a custom flarum console command rather than scraping the API — you avoid token handling and get direct DB access for date bucketing.
/api/statistics requires admin permission. Regular user tokens get a 403. For automation, mint a dedicated admin token or expose your own read-only endpoint in a custom extension if you want public stats.created_at, snapshotting, or disabling the widget for non-essential admins.APP_TIMEZONE/DB timezone consistently and document it.whereNull('hidden_at') conditions.php flarum cache:clear; in production also republish assets. A stale admin bundle is the usual cause of "the widget disappeared."vendor/ — Composer will overwrite it. Do it through a companion extension with override() and a proper extend.php./api/statistics call and status code, storage/logs/flarum.log for backend errors, php flarum info to confirm the extension is listed and enabled.How can I help you explore Laravel packages today?