• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

The Ultimate Start Here Thread for XenForo 2 Add-on Development

LPH

Flight Director
Flight Instructor
Learning to code takes years of practice. Don't expect to be an expert in 24-hours.

During your adventure, there will be humps, lumps, grumps, and ultimately the joy of coding. During the bumps, you will feel dumb. I don't like not understanding and feeling dumb but it's a reality that studying is vital to add-on development. Reading is fundamental.

Purpose
This post is to add guidance to learning how to create add-ons for XF2. It is an approach to learning from the documentation and available resources. There are obvious steps and maybe some missteps people have taken which can be avoided by creating a thread of tips on getting started.

Philosophy
In my view, learning the basics in PHP is acceptable only to a point. It's important that you set realistic expectations and not to expect a 24-hours to master XF2 add-on building. It's also okay to fail, and consider the experience as a First Attempt In Learning.

Keep in mind the following four points throughout your adventure:
  • Be patient
  • Keep your eyes and mind open
  • Take advice
  • Think twice before posting

Getting Started

Step One
Quickly scan all of the documentation.

Step Two
Read the documentation taking notes. Use the PHP manual to look up concepts.

Step Three
Read the development forum postings by Mike. These are pointed out in the documentation
Step Four
Download the preview. Install it. Look at the file structure.

Step Five
Walk through the build an add-on example. Download the zip file and read through the code. Add snippets to your notes.

Step Six (Novice / Hobbyists)
Learn basic OOP concepts such as class, objects, object notation, use of $this, scope operators, constructors, extending a class or model.

Learn basic Model, View, Controller (MVC) concepts.

If you are not using an IDE then find one now. Stop right now. Don't try to use notepad++ or Atom. Consider PhpStorm, the XF developers use it. Learn the IDE tips and tricks, too. Watch videos on how to complete things.

If you don't know any PHP then I suggest going to Laracasts and watching the videos. The PHP Practitioner is fantastic. There are excellent ones on the basics. PhpStorm also has great videos.

Learn Composer and Autoloading.

Learn Namespaces.

Step Seven
Learn about Entities, Repositories, and The Finder. Specifically look at the sample code in the documentation as well as in XF2. Within the text is an Hello World. Create it !

Step Eight
Use your test environment to build the sample add-on again. Yes. You did it once. Now do it again ! This time pay attention to your new knowledge from steps six and seven and try to understand each file being built.

Step Nine
Review the template system.

Step Ten
Use dump in PHP files and in templates. Read the output. In fact, learn how to debug in general.

Now you are ready to go back through the documentation and try your own add-on.

If you become stuck then search the documentation for examples, search through the XF code, search stack exchange, search through the PHP manual, and search through the development forum. If after all these searches and you are still unclear then ask and be thankful when someone answers.

Note: Of course, I'm open to editing this post to include your thoughts too. Your mileage may vary.
 
Top