There would be multiple ways for hosting an iframe with its own style and script inside of a Flarum.
- Have some or all of the files as assets. By placing them in an
assets
folder, Flarum will automatically copy the files over to the public assets. The downside is that the copy only happens when the extension is enabled, so if the plugin has an update, the forum owner must disable and re-enable the extension in case assets changed. Likewise clicking "uninstall" is required for the files to be removed. I don't see this as a "pretty" solution for PHP files though, as ideally you'd want the assets folder to be free of executable files, and keeping it in the source makes extra sure it's always up to date in case a security vulnerability is found.
- Have the files in the composer package, and expose them by proxying them through Flarum routes. This has the benefit of keeping the filesystem clean and removing the extension with Composer automatically removes all files.
- Have only the PHP as part of a controller, and fetch everything else from a CDN (like I see you already do for the JS)
In this precise case, I think the best solution wouldn't be an iframe at all. A custom bbcode with included javascript could be enough. The js and/or css could be registered into Flarum assets and wouldn't result in additional files requiring to be exposed.
Regarding your boot error, you need to check the way you import the controller class. Classes can be loaded from namespaces using Composer's autoloader. I see you defined a namespace in composer.json
but it seems you're trying to import a class named folder
from the global PHP namespace.
In general, Laravel guides are a good introduction to the concepts used in Flarum, like namespaces, container, events. For controllers and routing we use a different library from Laravel, but the concepts are still largely the same.