1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF Add-on Development Flow - What to code first?

Discussion in 'XenForo Development Discussions' started by TheBigK, Feb 20, 2015.

  1. TheBigK

    TheBigK Well-Known Member

    I'm taking my steps into learning XF Add-on development and wish to understand the right flow or approach to adapt for the development. I'm looking for advice on what to code first?

    That is, if my add-on requires a new route; I start it by -
    1. Creating new route
    2. Followed by writing the controller
    3. Will switch to writing templates before completing the controller.
    4. Then Datawriter
    5. Followed by Model
    6. Views at the end.
    But then, I began wondering if the entire process would be easier if I started by building the templates first. Another thought is to build the back-end first and then build all the public interface.

    What do you suggest?
  2. Jon W

    Jon W Well-Known Member

    My rough flow (usually):
    1. Installer
    2. Datawriter
    3. Model
    4. Controller
    5. Route
    6. Templates
    Really depends what I'm doing though, and not always that straight forward.

    For this sort of add-on development, I have some tools that I might be willing to release if there was enough interest.
  3. TheBigK

    TheBigK Well-Known Member

    What kind of tools and what problem do they help solve?
  4. Jon W

    Jon W Well-Known Member

    Tools that automate the process of creating datawriters, models, controllers, etc.
  5. BamaStangGuy

    BamaStangGuy Well-Known Member

    Would be interested in these.
  6. Daniel Hood

    Daniel Hood Well-Known Member

    Hmm It's interesting how differently we do things.

    I always do my installer last, otherwise I have to commit to the db schema I originally had in mind [unlikely] or I have to go back and adjust the installer [multiple times].

    I don't write anything entirely in one stage (except the Route and the DataWriter as they are small and usually standard, except for _postSave, _preSave, delete).

    Typically I go:

    1. Create the database table(s) in phpmyadmin:
    2. Create the route
    3. Create the controller with the action to display the form and save the form
    4. Create the template
    5. Create the datawriter (note that 3, 4, and 5 are interchangable)
    6. Add a controller action to view a list of data
    7. Create the model with methods for showing/preparing the list of data
    8. Create the template to display the list view of data
    9. Add a controller action to view one row of data
    10. Create the model with methods to show one item
    11. Create the template to display one item
    12. Add controller action to edit a row
    13. Create template to edit a row
    14. Add controller action to delete a row
    15. Create template to delete a row
    16. Views aren't required but if I need them for ajax responses (typically all I need them for really), I'll make them as I need them or at the end
    17. Create all the phrases (I like to do them all at once so I'm not in and out of the admin panel and risk missing one).
    18. Create the installer (once the add on is done, the schema is set so I export the structure and go off that).
    Claudio and TheBigK like this.
  7. Jon W

    Jon W Well-Known Member

    Where you go to PhpMyAdmin to edit your database, I basically just edit my installer and run it again.
    Daniel Hood likes this.
  8. NixFifty

    NixFifty Well-Known Member

    What kind of tools are these? Like are they integrated in to the ACP or something different? I have some CLI tools that I use (which can be executed from most IDEs), plus a couple other things. Been tidying up the code recently and was thinking of releasing them to aid others too.
  9. Jon W

    Jon W Well-Known Member

    Mine are all ACP tools.
  10. Jon W

    Jon W Well-Known Member

  11. Lawrence

    Lawrence Well-Known Member

    For me, typically:

    Phrases (error phrases for the datawriter, controller, permissions)
    Phrases (for the template <- I really dislike this part)
  12. Brogan

    Brogan XenForo Moderator Staff Member

    I always did do things a little differently.

    I start in the ACP first with the perms, options, admin templates, etc.
    Then move on to the code.
  13. batpool52!

    batpool52! Well-Known Member

    Something like phalcon dev tools? I have mine as well but they work only in Windows :p
  14. tyteen4a03

    tyteen4a03 Well-Known Member

    Everything jumbled together, but usually in this order: Model, DW, Templates/Phrases (together), ACP stuff, Installer
  15. Liam W

    Liam W Well-Known Member

    I don't really follow a set structure, although I generally always start with creating the directory structure and the Addon.php file that houses the installer & event listener methods.

    Then I create my installer, and call it from the methods...

    Then I do the rest, which is generally all over the place - I generally add phrases as I mention them in code, same with templates.


Share This Page