A template for developing addons for xenforo locally using docker containers to replicate a server experience using PHP-FPM, Nginx & MariaDB. All ports are exposed for easy access when querying the DB locally, or using xdebug in your IDE.
- docker-ce installed with respective command line
- docker-compose cli installed
- a copy of xenforo downloaded from the accounts panel
You will only need to run these steps on the first run. So long as you don't destroy the docker Volumes, you can just run Step 3 again to restart the env
-
Download a copy of xenforo 2 from your account panel, place into this directory and rename as
xenforo.zip -
Run
./install-from-zip.shto unpack the xenforo source -
Run
docker-compose up -dto start the containers -
Run
docker exec xenforo php cmd.php xf:install --user=admin --password=admin --clearto run the database migrations -
Rename
src/addons/Acme/My-Addon/to the relevant org name and addon name in both the file structure,config.phpand the.gitignorefile -
Run
docker exec -it xenforo php cmd.php xf-addon:createto create your addon
Note: you can run step 2 again if you need to restore any default xenforo files to default
Because FPM is running on it's default port of 9000 and exposed on your host, you will need to change a few defaults with PHPstorm to get things working. I recommend the this youtube video as a guide.
Note: the IDE key is set via
.docker/xdebug.inifile. By default, it is set todocker.
If you accidentally changed one of the core XF files during development, and you want to wipe and reinstall Xenforo source, just run ./install-from-zip.sh and choose to wipe and unpack the source once again.
If you want to use the xenforo CLI to it's full extent, you can execute it via the docker CLI to run within the PHP container
docker exec -it xenforo php cmd.phpIt's important to keep the -it after docker exec, so that we attach to the output of the command in case there are any input prompts
The config file for this setup exists in the root directory, not the usual src/config.php. Feel free to make whatever edits you like to the config file.
Note: You may see that there is also a
src/config.phpthat exists. This is an artifact of how docker binds our local config inside the xenforo source code volume. It's fine that it's empty, just leave that file as is.
To quickly kill the collection of containers
docker-compose killTo remove/delete them
docker-compose rmKill/Remove from anywhere on the host
docker <kill/rm> $(docker ps -f name="xenforo*" -q)Remove all associated volumes
docker volume rm $(docker volume ls -f name="xenforo*" -q)