This document is a guide for developers who want to contribute code to Flarum. If you're just getting started, we recommend that you read the Concepts documentation in the Extension docs to understand a bit more about how Flarum works.

Next, ensure that Composer accepts unstable releases from your local copies by changing the value of minimum-stability from beta to dev in composer.json.

Finally, run composer install to complete the installation from the path repositories.

Flarum's front-end code is written in ES6 and transpiled into JavaScript. During development you will need to recompile the JavaScript using Node.js. Please do not commit the resulting dist files when sending PRs; this is automatically taken care of when changes are merged into the master branch.

cd packages/core/js
npminstallnpm run dev

The process is the same for extensions, except you should link the core JavaScript into the extension so that your IDE will understand import from '@flarum/core' statements.

In order to keep the Flarum codebase clean and consistent, we have a number of coding style guidelines that we follow. When in doubt, read the source code.

Don't worry if your code styling isn't perfect! StyleCI will automatically merge any style fixes into Flarum repositories after pull requests are merged. This allows us to focus on the content of the contribution and not the code style.

Flarum follows the PSR-2 coding standard and the PSR-4 autoloading standard. On top of this, we conform to a number of other style rules. We use PHP 7 type hinting and return type declarations where possible, and PHPDoc to provide inline documentation. Try and mimic the style used by the rest of the codebase in your contributions.

Namespaces should be singular (eg. Flarum\Discussion, not Flarum\Discussions)