Auto-Loading PHP Script Widgets

The architecture for an application I created for a client required a method to auto-load a set of widgets (aka: individual PHP scripts) located in the “widgets” directory on the server.  This solution worked perfectly.

Of course, you can enhance this script by refactoring it into a function and adding additional filters to allow only certain types of files to load, like those prefixed with “widget-“.

Author: Richard Soares

I’m a freelance software developer with more than 20 years’ professional experience in web development. I specialise in creating tailor-made, web-based systems that can help your business run like clockwork.