Here is a short reference of some points in source code, which should help you to create XenForo 2 add-on. At first, I recommend you follow the official tutorial with an add-on sample.
You can find it here:
Below you will find additional information I discovered during writing my add-on.
I usually use Docker for such kind of app. I worked on an app with Memcached, so you will see it in the files below.
Here is the content of
And the content of
If you want to use HTTPS locally read the tutorial How to get HTTPS working on localhost to know more.
Enter a Docker container with command:
docker exec -it -u www-data php_container bash
Then you can list all commands and filter them:
$ php cmd.php | grep addon
Add-on commands located in src/XF/Cli/Command/AddOn folder.
All add-ons stored in src/addons folder and
xf_addon table in the database.
If you change tables with alters, use available data types from here:
Change tables with SchemaManager. See available methods in
src/XF/Db/SchemaManager.php, i.e. tableExists(), columnExists() etc.
The simplest way to extend an entity is to add it in the admin panel. See Development - Class extensions menu in the admin control panel.
It will write data to
xf_class_extension table. Classes extensions will be processed here:
src/XF/Extension.php::extendClass. XenForo extends with
class_alias PHP function. As a parent class, you should specify a class name with “XFCP_” prefix, see how it works here:
XenForo 2 sends a lot of events through request processing. See the list of events and event listeners in Development - Code events and Code event listeners in the admin control panel. Data will be stored in database in tables
In order to see all events, you could use Xdebug. Set a breakpoint in
src/XF/Extension.php::fire function and see event names and hints which you could use.
Here is a good tutorial on how to use it:
See the list of default functions you can use in templates in file