基于模块的php系统

shu*_*uwo 4 php module

我正在尝试制作基于模块的php系统.

每个模块都是一个实现模块接口并与php文件同名的类.每个模块都位于名为Modules的目录中.

我可以列出目录中的每个模块,但是如何获取它们的实例?它甚至可能吗?

一个小伪代码,使其更容易理解:

    foreach(scandir($module_dir) as $file){
        include $file
        $module = new $file // How can i make this work??
 }
Run Code Online (Sandbox Code Playgroud)