Skip to content

ModuleRegistry fails if you have previously installed nWidart/laravel-modules #116

Description

@martindanielsson

If you like me got overwhelmed by trying to use laravel-modules first and then went to use this package, it will fail trying to read the bootstrap/modules.php file as this follows a different format if you've used laravel-modules.

Simple fix to get around is to just php artisan optimize:clear before trying to install modular to clear out the bootstrap/cache directory.
If you already installed it, just rm bootstrap/cache/modules.php to get it working again.

But this could probably be sanitized in ModuleRegistry by adding this:

protected function loadModules(): Collection
{
    if (file_exists($this->cache_path)) {
        return Collection::make(require $this->cache_path)
            ->mapWithKeys(function(array $cached) {
                if (! isset($cached['name'], $cached['base_path'], $cached['namespaces'])) {
                    return null;
                }
                
                $config = new ModuleConfig($cached['name'], $cached['base_path'], new Collection($cached['namespaces']));
                return [$config->name => $config];
            });
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions