Minis
A Flarum extension that is not really an extension.
Every Flarum installation comes with a file extend.php
which allows you use any Flarum extender without creating a full-fledged extension. For the past several years I have been writing several examples to show people how to use this. I thought it wise to move some of these into their own extension so that you can use these extenders with less code.
Your extend.php
lives in the root installation path of Flarum, next to config.php
and flarum
.
Installation
Install with composer:
composer require luceos/minis:"*"
Updating
composer update luceos/minis:"*"
Extenders
How to use
Inside your extend.php
in the Flarum installation path you will see some lines, at the bottom you will find something like:
return [
];
Between the [
and ]
you can add the follow extender snippets. I've given examples for each of them.
User - Email
Luceos\Minis\User\Email\RequireDomain
- limits the email domains that can sign up.
new Luceos\Minis\User\Email\RequireDomain('@flarum.org', '@gmail.com'),
Post - Throttle
Luceos\Minis\Post\Throttle\InTag
- throttles how fast a user can reply or create discussions in a certain tag
Allow replying and creating discussions only once every five minutes in the tag with slug advertisements
.
(new Luceos\Minis\Post\Throttle\InTag('advertisements'))
->op(true)
->reply(true)
->interval(fn (\Carbon\Carbon $carbon, \Flarum\User\User $user) => $carbon->subMinutes(5)),
Check the Carbon documentation in how to use the interval settings with carbon: https://carbon.nesbot.com/docs/#api-addsub.
Allow creating discussions only once every day in the tag with slug advertisements
.
(new Luceos\Minis\Post\Throttle\InTag('advertisements'))
->op(true)
->interval(fn (\Carbon\Carbon $carbon, \Flarum\User\User $user) => $carbon->subDay()),
Post - Formatting
Luceos\Minis\Post\Formatting\AllowElement
- allows using a html element in the editor/composer
new Luceos\Minis\Post\Formatting\AllowElement('iframe'),
Links