This is meant as an extension (no pun intended) of this. Please read that first.

Hello Everyone!

I've been making extensions for about 3 months now and I've learned a few things along the way that has made my life easier, and I'm here to share those things with you. I hope you can benefit from these, and if you have any other tips feel free to leave a comment!

1. Use an IDE

I can't tell you how many times my code has broken because I forgot a colon or bracket. If you don't know already, IDE stands for Integrated Development Environment and helps you develop by highlighting syntax errors, autocomplete and more. I recommend PHPstorm for PHP and JavaScript. PHPstorm is made by JetBrains. The entire JetBrains suite is free for students.

2. Use XAMPP to run your test environment

I've seen tons of complaints about Flarum's subpar error reporting. With a few exceptions, any problem in the backend (PHP) will return a 500 internal server error. For reasons unknown to me (mostly because I haven't looked into it) XAMPP will give you more helpful errors, this is extremely helpful for debugging your code.

3. Start small

This should go without saying but don't start on the most complicated extension. My first extensions were old extensions that I fixed up to work on the latest versions of Flarum.

4. Look at other extensions' code

You can learn a ton from other extensions code. If you get stuck, see if another extension does something similar, try to figure out how it does it. At the time of writing this, most (if not all) extensions (including Flarum) are licensed under MIT. This means that you are free to copy code and use it in your projects.

5. Ask for help

The Flarum community has several ways to get in touch with other developers on the Official Discord server. This was one of the most helpful things for me. Others have likely made the same mistakes and spent lots of time solving them, so you don't have to.

6. Have fun

If you get frustrated, take a break. No one is forcing you to do what you are doing. I've found that taking a break when I'm stuck and giving my brain a rest allows me to come back with fresh eyes, and I usually solve the problem pretty quick.

I hope you all got something out of this that will help your developing. I'm excited to see what you guys come up with. We as a community would like to thank you for all the hours you put into it.

Finally I'd like to give a shout to @luceos for helping me get starting making extensions, and his continued support.

3 years later

Not sure if I'm at the right place, but are there any plans to extend the documentation? It's currently pretty poor and I think it would be a huge win if there would be clear docs. People would be able to contribute and create extensions much faster...

    bobmulder yes Bob, we do have plans for that. But our focus right now is to get to stable first and merge huge changes to our frontend. These frontend changes would void any attempts at improving that side of the docs.

      luceos Got it! Not meant to push you, just wanted to know if this was in your sight 😉 Good luck and above all have fun 🙂

      bobmulder @clarkwinkelmann's videos helped me get started with building extensions. His videos can be found on Videos on how to extend Flarum or his YouTube channel, Clark Writes Code.

      This was the first video I saw. It was a little tough to start but it gets easier. You'll have to know how to code in PHP, JS and Mithril (Which is super easy).

      Hope to see you publish some extensions of your own. If you have any questions you can always ask them here on Discuss or the #extend channel at the Discord server.

        3 years later

        luceos Sir, do I have to use XAMPP in my Ubuntu device to serve the flarum locally or is there any better alternative to this?

          Bishwas-py on ubuntu you can use something like valet which runs nginx: https://laravel.com/docs/9.x/valet#introduction or you could alternatively install a whole LAMP stack (apache, mysql, php). Valet takes away the need for that if I'm not mistaken. There are plenty of other tools for Linux distro's to run a full fledged web service though, but that's the one I know of well.

            luceos Thanks for the reply. I simply used the PHP Built-in Web Server feature provided in Php Storm.

              2 years later

              The very first link "Building extensions documentation" is broken in the main article that this one extends.