Module Development Environment

Sorry for the rather noob question. Although I have been doing programming casually for many years in various languages, all the way back to BASIC and C, my usual is Java, but I have done some things in PHP, so the syntax is familiar. What is the best or correct environment for FreePBX module development? I have been an Eclipse user for years, but I am not familiar with how to set up a programming environment for web apps like FreePBX. I have some (not much) knowledge of CSS and more of the old-school HTML knowledge, but I lack an understanding of the file structure of how FreePBX is laid out and how that translates to the HTML you see. Is there a tutorial or article geared toward someone used to Java Swing and the GUI builder that explains how to lay out objects and JavaScript, and how they tie together in the files, in a more visual format? If Eclipse does not appear to do that, is there an IDE better suited to it? Also, I am a full-time Linux user, so it would have to be a Linux-based IDE. I have seen and downloaded the example module, but I am still having a hard time wrapping my head around it. I have done some of the non-GUI parts of PHP in FreePBX, like dialplan, AGI, and PHP scripts, but I get lost in the various files and how they interact. Something that can tie them together and give a better visualization would be helpful. I am sure that once it’s explained from my perspective, it will click and make a lot more sense. I feel I am just missing something. I am sure FreePBX is not the only thing out there using that file structure and development method. Thanks

Coming from Java Swing, the biggest adjustment is giving up the drag-and-drop GUI builder. You write the HTML, CSS, and PHP logic directly. FreePBX uses an architecture called BMO (Big Module Object). It is essentially a giant, obnoxious monolith that holds all your autoloaded classes. Pro tip: never run a var_dump on the root BMO object unless you enjoy flooding your terminal with useless text.

Since you run Linux natively, ditch Eclipse for Visual Studio Code. You can run VSCode locally and use the Remote SSH extension to edit files directly on your dev server. I stick to Prettier for code formatting and Psalm for static analysis.

I usually spin up a VM in Proxmox or VMware Workstation Pro. Install Ubuntu and run the standard FreePBX 17 installation script.

Keep your active code in /usr/src and symlink it to the FreePBX web root. This gives you a permanent workspace where you can build the scaffolding, link it to the live directory, and edit the code in place.

	ln -s /usr/src/worldscoolestmodule /var/www/html/admin/modules/worldscoolestmodule
	fwconsole ma install worldscoolestmodule

The file structure looks chaotic at first, but modules are self-contained. Here is the basic layout.

  • page.worldscoolestmodule.php: The main UI entry point. It sets up the page framework and calls your views. In the module.xml you will set <menuitems/> which is what derives the page.whatever.php if you have multiple UI entry points.
  • views/: This holds your HTML and PHP templates. FreePBX relies on Bootstrap 4. You build the UI by writing standard HTML wrapped in Bootstrap classes.
  • assets/js/ and assets/css/ or even assets/less/: Drop your custom JavaScript and stylesheets here. FreePBX automatically links them based on the module name.
  • Worldscoolestmodule.class.php: The core logic class. This handles database interactions, generates configuration data, and processes AJAX requests.

Check out these resources to get moving.

Thanks for all that information. Some I know, but I have not seen the link to the community page, and it looks like I have a lot of reading to get through. I kind of assumed there were no direct GUI-building tools for web apps, which is kind of sad, since Java tools have been out for so long and make a GUI so easy that you get to spend way more time on the code than on the GUI. I guess that explains why web apps like FreePBX and others I have seen have more basic GUIs and seem to lack features like table editing; you spend a lot more time troubleshooting the GUI or the look and feel. I guess I have to go old school, like it was 20 years ago when I wrote in Tcl/Tk. That is also about the time I stopped doing HTML, so I have a lot to catch up on that (probably the last time I used JavaScript). I actually do have CodeVS installed as well. I used it to generate the firmware for my 3D printer; I guess I will have to play around with it more. I noticed that FreePBX uses Bootstrap 4, and I will have to read about that on w3schools, Hopefully that will help fill in the gaps. Again, thanks for the tips and info. Hopefully, at some point, I can get something functional done.