diff --git a/app/Services/Helpers/PluginService.php b/app/Services/Helpers/PluginService.php index 174afc83d..f1bb43705 100644 --- a/app/Services/Helpers/PluginService.php +++ b/app/Services/Helpers/PluginService.php @@ -50,6 +50,12 @@ class PluginService } } + // Autoload src directory to make sure all class names can be resolved (e.g. in migrations) + $namespace = $plugin->namespace . '\\'; + if (!array_key_exists($namespace, $classLoader->getPrefixesPsr4())) { + $classLoader->setPsr4($namespace, plugin_path($plugin->id, 'src/')); + } + // Filter out plugins that should not be loaded (e.g. because they are disabled or not installed yet) if (!$plugin->shouldLoad()) { continue; @@ -73,12 +79,6 @@ class PluginService }); } - // Autoload src directory - $namespace = $plugin->namespace . '\\'; - if (!array_key_exists($namespace, $classLoader->getPrefixesPsr4())) { - $classLoader->setPsr4($namespace, plugin_path($plugin->id, 'src/')); - } - // Register service providers foreach ($plugin->getProviders() as $provider) { if (!class_exists($provider) || !is_subclass_of($provider, ServiceProvider::class)) {