Skip to content

Commit

Permalink
fix service provider auto loading
Browse files Browse the repository at this point in the history
  • Loading branch information
norbybaru committed Nov 23, 2024
1 parent 78d1851 commit d974ad4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/ModularizeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,21 @@ private function autoloadConfig(string $moduleRootPath, string $module)
*/
private function autoloadServiceProvider(string $moduleRootPath, string $module)
{
$provider = "{$moduleRootPath}/{$module}/Providers/{$module}ServiceProvider.php";
$provider = "{$module}/Providers/{$module}ServiceProvider.php";
$file = "{$moduleRootPath}/$provider";
if ($this->files->exists($file)) {
$providerNamespace = $this->rootNamespace.str_replace(
['/', '.php'],
['\\', ''],
$provider
);

if ($this->files->exists($provider)) {
$this->app->register($provider);
if (
is_subclass_of($providerNamespace, ServiceProvider::class)
&& ! (new ReflectionClass($providerNamespace))->isAbstract()
) {
$this->app->register($providerNamespace);
}
}
}

Expand Down

0 comments on commit d974ad4

Please sign in to comment.