Some suggests on modules architecture

Hi all,
I’m developing some new modules of freepbx… i think that the architecture should be more MVC compliant as modern software suggests.
For example all that php for the view part should be avoided, why not we use a template language instead? The php should be used only for the model and controller part. This will bring to a more mantainable software and it also will be simpler to write for us.
Another suggest should be to use a common library (classes) to perform all that typical operations (like queries, writing, …) a module usually performs.

What do you think about?

We already do this. But it depends on what module you are looking at and how recently it was updated.

We have common classes for the database. Dialplan and are slowly adding others. If you want to add more feel free. It’s all part of bmo.

As for views. We are not currently focused on implementing any tempting engine. If you feel this is a requirement then by all means work on it and submit it. What we do now it break up views into the views folder. It’s straight php but that is ok depending on what module you are looking at. Implementing a full tempting engine like smarty comes at performance costs which we don’t want at this time.

1 Like

BMO
General Development stuff

#freepbx-dev on irc.freenode.net

My personal resources:



Ok… in my opinion with the actual code base the best choice to write views is to use html5 (as i’m doing). We have created a skeleton (following the daynight module) and a tool to do some sort of scaffolding in order to make new modules in a faster and standard way. We’ll submit all the code as soon as possible.

Thank you! very useful!

Awesome. We’ve been doing this already for the last three years. There are over 127 modules in the product. Not all of them have been updated (due to time). Some good examples are:

HTML5 Audio

  • System Recordings
  • Music on Hold

Websockets

  • UCP

Along with what James has posted above.

All styling changes from 12 to 13 use Bootstrap v3 which is “web 2.0/html5”.

In FreePBX 14 the minimum IE version is 10+. We’ve upgraded all javascript libraries to their latest. So jQuery 3.0, jQueryUI 1.12.1 (We are not a fan of jQUI but it’s needed for some legacy modules).

Some notes:

  • functions.inc.php was the old controller. But .class.php is the new way.
  • We didn’t ever add something like smarty because of performance loss (however with php5.6 -7 this may no longer be an issue)
  • FreePBX originally used the pearDB database abstraction library. We’ve moved everything to PDO, with a wrapper for pearDB. We also now use doctrine for database creation as we are on the path to supporting sqlite for Pi type systems. ( findmefollow/module.xml at release/14.0 · FreePBX/findmefollow · GitHub )
  • Everything is thus done through FreePBX::Database()