3.3. Modularity

If you look at the ByteHoard code, you should notice one very important thing; everything is modularised. This is important, and shouldn't be too unfamiliar to many developers, but I'd just like to explain the details.

The modules are not grouped in any particular way; they are simply PHP files in the modules/ directory. When a new one is found, ByteHoard reads its name, description and author into the database, but where they are linked to and for whom is all specified in the database.

NoteWhat they were used for and by whom used to be specified in the files themselves, but i decided that a database-based approach would be much better and more flexible, even if it does require a bit more work in the code when adding or removing modules.

Even the core functions themself are modules - when a page is loaded, the index.php file simple loads the BH libraries, checks the current user is allowed to access the page (and perhaps does a login/logout), and then hands complete control over to the module. This allows for a lot of power - modules can do whatever they want. You could even install a CMS or a wiki in the modules directory, make the appropriate change of main file names (or use an include) and ByteHoard would quite happily pass control to it, and it would output correctly. Modules can use the layout & templates at their own discretion; it would be silly not to, but it might be necessary, and in the case of the download and filelink modules, the module only wants to spit out the file and then exit.