Im making an plugin, which loads plugins from an directory which is set in the config. Now, the plugins are getting loaded but other plugins cant access the classes from these plugins. I tried this Code: foreach (glob("/home/atomic/plugins") as $file) { // get the file name of the current file without the extension // which is essentially the class name $class = basename($file, '.php'); if (class_exists($class)) { $this->getServer()->getLoader()->loadClass($class); } } but it didnt work. The plugins are all in phar format. I get this error when trying to access the classes from other plugins: Does somebody know how to load the classes?
You should add them as dependencies in the plugin.yml, to make sure the needed plugins load first. edit: my bad, misread the OP.
You fundamentally misunderstand class loading. `class_exists()` will return `false` for a not-loaded class. Additionally, `BaseClassLoader->loadClass()` is not supposed to be called by external things. You should add the `plugins` directory to the loader path instead of doing this. However, this makes no sense anyway because script plugins already have this functionality.