Updating For 1.x
Flarum v1.2 included quite a few bugfixes, internal refactors, and new features. The following recaps the most important changes for extension developers:
- Flarum core now passes TypeScript type checking (on the portion written in TypeScript). Additionally, major portions of the frontend (models, the application instance, and others) are now written in TypeScript. These changes should make it much easier and more fruitful to write extensions in TypeScript.
- Instead of directly using Less variables in CSS code, core now uses CSS variables. For the most part, we've just created CSS variables and set their values to the Less variables. This should make theming and customizing CSS a lot easier. https://github.com/flarum/core/pull/3146.
- Dropdowns can now be lazy-drawn to improve performance. You can do this by setting the lazy draw attr to "true". https://github.com/flarum/core/pull/2925.
- Textarea-type settings are now supported through the
- You can now use Webpack 5 to bundle your extension's code. This will offer minor bundle size improvements.
- A new
flarum/common/components/ColorPreviewInputcomponent has been added. It can be used directly, or through the
color-previewtype when registered via
- Extensions can now modify the minimum search length of the
- The following components are now extensible:
- Extensions now have finer control over positioning when adding elements to the DiscussionPage sidebar items: https://github.com/flarum/core/pull/3165
- An extender for settings defaults has been added. This should be used instead of the
addSettingsmigration helper, which has been deprecated.
- You can now generate Less variables from setting values via the
- Extensions can now override/supplement blade template namespaces through the
Viewextender, meaning custom blade templates can be used instead of the default ones added by core or extensions.
- You can now define custom Less functions through PHP, allowing you to use some backend logic in your Less theming.
- Extensions can now create custom page title drivers for titles in server-returned HTML.
- Custom logic can now be used when deciding which relations to eager-load.
- Events are now dispatched for the
ImageManagerinstance is now bound into the container, and can be configured to use either the
imagickbacking drivers via the
- User IP addresses are now passed to the API Client.
- A custom revision versioner implentation can be set via container bindings to customize how asset versions are named.
- A SlugManager instance is now available in blade templates via the
- Translations now support the
manylocalized plural rules for
pluralICU MessageFormat translations. This was done through the
- Translations are now used for page titles, so that the format can be customized via language packs or Linguist: https://github.com/flarum/core/pull/3077, https://github.com/flarum/core/pull/3228
- API endpoints for retrieving single groups, as well as support for filtering groups on the plural get endpoint, have been added.
flarum-cli infracommand can now be used to update or enable various infrastructure features. You can now add the following to your extension in just one command:
- Prettier for JS/TS formatting
- Backend testing with PHPUnit
- Code formatting with StyleCI
- EditorConfig support
- GitHub actions for automating testing, linting, type checking, and building.
- You can also exclude any files from these updates by adding their relative path to the "extra.flarum-cli" key's array in your extension's
composer.jsonfile. For example, if you wanted to exclude your tsconfig file from any updates by the infra system, the "extra.flarum-cli" key's value should be
flarum-cli audit infracan be used to check that all infra modules your extension uses are up to date. The
--fixflag can be used to automatically fix any issues, which has essentially the same effect as running
flarum-cli infrafor each outdated module.
flarum-clicommands can now be run with a
--no-interactionflag to prevent prompts. Defaults will be used when possible, and errors will be thrown if a prompt is needed and there is no default.
- Frontend GH actions now support type-checking, as well as type coverage reports.
Flarum version 1.1 mostly focuses on bugfixes and quality-of-life improvements following our stable release earlier this year. These are mainly user-facing and internal infrastructure changes, so extensions are not significantly affected.
- Flarum now has an organization-wide prettier config package under
- Most custom (setting or data based) coloring in core is now done via CSS custom properties.
- Typehinting for Flarum's globals are now supported in extensions.
- You can now pass extra attrs to the
Selectcomponent, and they will be passed through to the DOM.
DiscussionPagecomponent is now organized as an item list, so it's easier for extensions to change its content.
- Extensions can now edit the