Start free trial

Extensions (PHP) · Making an extension

Making an extension with fs:make

fs:make writes the code for each part of an extension, so you start from something that already works. Every command has a form in the admin panel under Developer that writes the same files.

What it makes

CommandWhat you get
fs:make extension vendor/nameA new extension with one page.
fs:make page mapA page with its route and view. Forum pages go in routes/guest.php or routes/member.php, admin pages in routes/admin.php.
fs:make table pinsA migration for a new table in the current version's folder.
fs:make listener PinTopicsA class in src/Listeners that runs when something happens on the forum.
fs:make task CleanUpA job in src/Jobs that runs on a schedule.
fs:make permission add_pinsA per-forum permission admins set in Groups.
fs:make activity "New pins"A source for the forum's Activity page and its unread count.

When your workspace holds more than one extension, add its id at the end: fs:make page map harbour/member-map.

The extension class

namespace Harbour\MemberMap;

use App\Extensions\BaseExtension;

class Extension extends BaseExtension
{
    public function name(): string
    {
        return 'Member map';
    }
}

Your class extends BaseExtension. You never edit ForumSpark's own files or replace its classes: you add pages, tables and listeners, and ForumSpark calls them.

Only on forums that install it

An extension is loaded only on the forums that installed and turned it on. Its tables, files and settings belong to that forum. If it keeps failing, ForumSpark switches it off on that forum and tells the admin, so one broken extension never takes a forum down.