it-novum / openITCOCKPIT

openITCOCKPIT is an Open Source system monitoring tool built for different monitoring engines like Nagios, Naemon and Prometheus.
https://openitcockpit.io/
GNU General Public License v3.0
273 stars 50 forks source link

support composer autoload for (third-party) openITCOCKPIT modules #1578

Closed binsky08 closed 11 months ago

nook24 commented 11 months ago

Looks good to me, thanks!

nook24 commented 11 months ago

Unfortunately I had to revert this change, as it introduces unexpected behavior and fatal errors when a Module loads old versions of libraries. For example if the Module (or CakePHP plugin) uses an old version of CakePHP you run into PHP fatal error messages like this:

'Unknown method "selectQuery" called on App\\Model\\Table\\AgentchecksTable'
binsky08 commented 11 months ago

hmm, that's not the expected behaviour xD

But is there any other way to psr4 autoload plugin dependencies? Or more general, is there a way to use plugin (composer) dependencies that are not already loaded by the core?

The PluginManager.php does not respect the plugins composer.json autoload section. Instead it injects only the module namespace in a hardcoded way (and expect it to be in /src). see line 86-89:

grafik

Maybe something like parsing the plugins composer.json autoload section and using that $loader->setPsr4 for every autoload entry?