nWidart / laravel-modules

Module Management In Laravel
https://docs.laravelmodules.com
MIT License
5.51k stars 956 forks source link

Laravel 6.0-dev - module:install from packagist #818

Closed mbehnke closed 5 years ago

mbehnke commented 5 years ago
[root@591e9c2e1082 html]# php artisan module:setup
Modules directory created successfully
Assets directory created successfully
[root@591e9c2e1082 html]# php artisan module:list
+------+--------+-------+------+
| Name | Status | Order | Path |
+------+--------+-------+------+
[root@591e9c2e1082 html]# php artisan module:install rwth-itcenter/br-module
./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Nothing to install or update

Generating optimized autoload files

> Illuminate\Foundation\ComposerScripts::postAutoloadDump

> @php artisan package:discover --ansi

Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision

Discovered Package: nwidart/laravel-modules

Discovered Package: rwth-itcenter/br-module

Package manifest generated successfully.

Running for module: BrModule

   Nwidart\Modules\Exceptions\ModuleNotFoundException  : Module [BrModule] does not exist!

  at /var/www/html/vendor/nwidart/laravel-modules/src/FileRepository.php:406
    402|         if ($module !== null) {
    403|             return $module;
    404|         }
    405|
  > 406|         throw new ModuleNotFoundException("Module [{$name}] does not exist!");
    407|     }
    408|
    409|     /**
    410|      * Get all modules as laravel collection instance.

  Exception trace:

  1   Nwidart\Modules\FileRepository::findOrFail("BrModule")
      /var/www/html/vendor/nwidart/laravel-modules/src/Process/Updater.php:16

  2   Nwidart\Modules\Process\Updater::update("BrModule")
      /var/www/html/vendor/nwidart/laravel-modules/src/FileRepository.php:613

  Please use the argument -v to see more details.
nWidart commented 5 years ago

Did you configure it to scan the vendor folder?

mbehnke commented 5 years ago

No.

[root@a71c9b62fa3d html]# php artisan module:install rwth-itcenter/br-module
./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Package operations: 1 install, 0 updates, 0 removals

  - Installing rwth-itcenter/br-module (dev-master 0d8fa88): 
Cloning 0d8fa88fbf

Writing lock file
Generating optimized autoload files

> Illuminate\Foundation\ComposerScripts::postAutoloadDump

> @php artisan package:discover --ansi

Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker

Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nwidart/laravel-modules
Discovered Package: rwth-itcenter/br-module
Package manifest generated successfully.

Running for module: BrModule

   Nwidart\Modules\Exceptions\ModuleNotFoundException  : Module [BrModule] does not exist!

  at /var/www/html/vendor/nwidart/laravel-modules/src/FileRepository.php:406
    402|         if ($module !== null) {
    403|             return $module;
    404|         }
    405| 
  > 406|         throw new ModuleNotFoundException("Module [{$name}] does not exist!");
    407|     }
    408| 
    409|     /**
    410|      * Get all modules as laravel collection instance.

  Exception trace:

  1   Nwidart\Modules\FileRepository::findOrFail("BrModule")
      /var/www/html/vendor/nwidart/laravel-modules/src/Process/Updater.php:16

  2   Nwidart\Modules\Process\Updater::update("BrModule")
      /var/www/html/vendor/nwidart/laravel-modules/src/FileRepository.php:613

  Please use the argument -v to see more details.
[root@a71c9b62fa3d html]# php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"

Copied File [/vendor/nwidart/laravel-modules/config/config.php] To [/config/modules.php]
Publishing complete.
[root@a71c9b62fa3d html]# 
[root@a71c9b62fa3d html]# php artisan module:install rwth-itcenter/br-module
./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Nothing to install or update

Generating optimized autoload files

> Illuminate\Foundation\ComposerScripts::postAutoloadDump

> @php artisan package:discover --ansi

Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nwidart/laravel-modules
Discovered Package: rwth-itcenter/br-module
Package manifest generated successfully.

Running for module: BrModule

   Nwidart\Modules\Exceptions\ModuleNotFoundException  : Module [BrModule] does not exist!

  at /var/www/html/vendor/nwidart/laravel-modules/src/FileRepository.php:406
    402|         if ($module !== null) {
    403|             return $module;
    404|         }
    405| 
  > 406|         throw new ModuleNotFoundException("Module [{$name}] does not exist!");
    407|     }
    408| 
    409|     /**
    410|      * Get all modules as laravel collection instance.

  Exception trace:

  1   Nwidart\Modules\FileRepository::findOrFail("BrModule")
      /var/www/html/vendor/nwidart/laravel-modules/src/Process/Updater.php:16

  2   Nwidart\Modules\Process\Updater::update("BrModule")
      /var/www/html/vendor/nwidart/laravel-modules/src/FileRepository.php:613

  Please use the argument -v to see more details.

after:

php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"

in config/modules.php:

    'scan' => [
        'enabled' => false,
        'paths' => [
            base_path('vendor/*/*'),
        ],
    ],
mbehnke commented 5 years ago

additional i tried ... joshbrw/laravel-module-installer (is it deprecated?)

[root@a71c9b62fa3d html]# composer require joshbrw/laravel-module-installer
Using version ^0.1.4 for joshbrw/laravel-module-installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing joshbrw/laravel-module-installer (v0.1.4): Downloading (100%)         
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

In ProviderRepository.php line 208:

  Class 'Modules\Backup\Providers\BackupServiceProvider' not found  

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json to its original content.
mbehnke commented 5 years ago

after cleanup and retry with

laravel-module-installer

[root@a71c9b62fa3d html]# composer require rwth-itcenter/br-module         
Using version ^1.0 for rwth-itcenter/br-module
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing rwth-itcenter/br-module (1.0.0): Downloading (100%)         
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nwidart/laravel-modules
Discovered Package: rwth-itcenter/br-module
Package manifest generated successfully.
[root@a71c9b62fa3d html]# composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Removing rwth-itcenter/br-module (1.0.0)
  - Installing rwth-itcenter/br-module (dev-master 0d8fa88): Downloading (100%)         
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nwidart/laravel-modules
Discovered Package: rwth-itcenter/br-module
Package manifest generated successfully.
[root@a71c9b62fa3d html]# php artisan module:list
+--------+----------+-------+----------------------------------------------+
| Name   | Status   | Order | Path                                         |
+--------+----------+-------+----------------------------------------------+
| Backup | Disabled | 0     | /var/www/html/vendor/rwth-itcenter/br-module |
+--------+----------+-------+----------------------------------------------+
[root@a71c9b62fa3d html]# php artisan module:enable Backup
Module [Backup] enabled successful.
nWidart commented 5 years ago

It looked like you had the vendor scanning feature disabled from your comments.

nWidart commented 5 years ago

I'll close this as there hasn't been a reply in a while, feel free to comment if needed.

abdulrahman19 commented 4 years ago

I have the same issue, I can't install packages by module:install

Laravel version is 6.2, Laravel-Module version is 6.1

/composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Package operations: 1 install, 0 updates, 0 removals

  - Installing abdulrahman19/test-module (dev-master 1080bb1): 
Cloning 1080bb1471 from cache

Writing lock file
Generating optimized autoload files

> Illuminate\Foundation\ComposerScripts::postAutoloadDump

> @php artisan package:discover --ansi

Discovered Package: abdulrahman19/test-module
Discovered Package: facade/ignition

Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon

Discovered Package: nunomaduro/collision

Discovered Package: nunomaduro/phpinsights

Discovered Package: nwidart/laravel-modules

Package manifest generated successfully.

ocramius/package-versions:  Generating version class...

ocramius/package-versions: ...done generating version class

Running for module: TestModule

   Nwidart\Modules\Exceptions\ModuleNotFoundException  : Module [TestModule] does not exist!

  at /var/www/html/learn/laravel/vendor/nwidart/laravel-modules/src/FileRepository.php:396
    392|         if ($module !== null) {
    393|             return $module;
    394|         }
    395| 
  > 396|         throw new ModuleNotFoundException("Module [{$name}] does not exist!");
    397|     }
    398| 
    399|     /**
    400|      * Get all modules as laravel collection instance.

  Exception trace:

  1   Nwidart\Modules\FileRepository::findOrFail("TestModule")
      /var/www/html/learn/laravel/vendor/nwidart/laravel-modules/src/Process/Updater.php:16

  2   Nwidart\Modules\Process\Updater::update("TestModule")
      /var/www/html/learn/laravel/vendor/nwidart/laravel-modules/src/FileRepository.php:590

  Please use the argument -v to see more details.

my package composer

{
    "name": "abdulrahman19/test-module",
    "type": "laravel-module",
    "description": "bla bla bla",
    "authors": [
        {
            "name": "Abdulrahman Asaad",
            "email": "eng.abdulrahman19@gmail.com"
        }
    ],
    "extra": {
        "laravel": {
            "providers": [
                "Modules\\Test\\Providers\\TestServiceProvider"
            ],
            "aliases": {

            }
        }
    },
    "autoload": {
        "psr-4": {
            "Modules\\Test\\": "."
        }
    }
}

my config file

<?php

use Nwidart\Modules\Activators\FileActivator;

return [

    /*
    |--------------------------------------------------------------------------
    | Module Namespace
    |--------------------------------------------------------------------------
    |
    | Default module namespace.
    |
    */

    'namespace' => 'Modules',

    /*
    |--------------------------------------------------------------------------
    | Module Stubs
    |--------------------------------------------------------------------------
    |
    | Default module stubs.
    |
    */

    'stubs' => [
        'enabled' => false,
        'path' => base_path() . '/vendor/nwidart/laravel-modules/src/Commands/stubs',
        'files' => [
            'routes/web' => 'Routes/web.php',
            'routes/api' => 'Routes/api.php',
            'views/index' => 'Resources/views/index.blade.php',
            'views/master' => 'Resources/views/layouts/master.blade.php',
            'scaffold/config' => 'Config/config.php',
            'composer' => 'composer.json',
            'assets/js/app' => 'Resources/assets/js/app.js',
            'assets/sass/app' => 'Resources/assets/sass/app.scss',
            'webpack' => 'webpack.mix.js',
            'package' => 'package.json',
        ],
        'replacements' => [
            'routes/web' => ['LOWER_NAME', 'STUDLY_NAME'],
            'routes/api' => ['LOWER_NAME'],
            'webpack' => ['LOWER_NAME'],
            'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
            'views/index' => ['LOWER_NAME'],
            'views/master' => ['LOWER_NAME', 'STUDLY_NAME'],
            'scaffold/config' => ['STUDLY_NAME'],
            'composer' => [
                'LOWER_NAME',
                'STUDLY_NAME',
                'VENDOR',
                'AUTHOR_NAME',
                'AUTHOR_EMAIL',
                'MODULE_NAMESPACE',
            ],
        ],
        'gitkeep' => true,
    ],
    'paths' => [
        /*
        |--------------------------------------------------------------------------
        | Modules path
        |--------------------------------------------------------------------------
        |
        | This path used for save the generated module. This path also will be added
        | automatically to list of scanned folders.
        |
        */

        'modules' => base_path('app/Modules'),
        /*
        |--------------------------------------------------------------------------
        | Modules assets path
        |--------------------------------------------------------------------------
        |
        | Here you may update the modules assets path.
        |
        */

        'assets' => public_path('modules'),
        /*
        |--------------------------------------------------------------------------
        | The migrations path
        |--------------------------------------------------------------------------
        |
        | Where you run 'module:publish-migration' command, where do you publish the
        | the migration files?
        |
        */

        'migration' => base_path('database/migrations'),
        /*
        |--------------------------------------------------------------------------
        | Generator path
        |--------------------------------------------------------------------------
        | Customise the paths where the folders will be generated.
        | Set the generate key to false to not generate that folder
        */
        'generator' => [
            'config' => ['path' => 'Config', 'generate' => true],
            'command' => ['path' => 'Console', 'generate' => true],
            'migration' => ['path' => 'Database/Migrations', 'generate' => true],
            'seeder' => ['path' => 'Database/Seeders', 'generate' => true],
            'factory' => ['path' => 'Database/factories', 'generate' => true],
            'model' => ['path' => 'Entities', 'generate' => true],
            'controller' => ['path' => 'Http/Controllers', 'generate' => true],
            'filter' => ['path' => 'Http/Middleware', 'generate' => true],
            'request' => ['path' => 'Http/Requests', 'generate' => true],
            'provider' => ['path' => 'Providers', 'generate' => true],
            'assets' => ['path' => 'Resources/assets', 'generate' => true],
            'lang' => ['path' => 'Resources/lang', 'generate' => true],
            'views' => ['path' => 'Resources/views', 'generate' => true],
            'test' => ['path' => 'Tests/Unit', 'generate' => true],
            'test-feature' => ['path' => 'Tests/Feature', 'generate' => true],
            'repository' => ['path' => 'Repositories', 'generate' => false],
            'event' => ['path' => 'Events', 'generate' => false],
            'listener' => ['path' => 'Listeners', 'generate' => false],
            'policies' => ['path' => 'Policies', 'generate' => false],
            'rules' => ['path' => 'Rules', 'generate' => false],
            'jobs' => ['path' => 'Jobs', 'generate' => false],
            'emails' => ['path' => 'Emails', 'generate' => false],
            'notifications' => ['path' => 'Notifications', 'generate' => false],
            'resource' => ['path' => 'Transformers', 'generate' => false],
        ],
    ],
    /*
    |--------------------------------------------------------------------------
    | Scan Path
    |--------------------------------------------------------------------------
    |
    | Here you define which folder will be scanned. By default will scan vendor
    | directory. This is useful if you host the package in packagist website.
    |
    */

    'scan' => [
        'enabled' => true,
        'paths' => [
            base_path('vendor/*/*'),
        ],
    ],
    /*
    |--------------------------------------------------------------------------
    | Composer File Template
    |--------------------------------------------------------------------------
    |
    | Here is the config for composer.json file, generated by this package
    |
    */

    'composer' => [
        'vendor' => 'abdulrahman19',
        'author' => [
            'name' => 'Abdulrahman Asaad',
            'email' => 'eng.abdulrahman19@gmail.com',
        ],
    ],
    /*
    |--------------------------------------------------------------------------
    | Caching
    |--------------------------------------------------------------------------
    |
    | Here is the config for setting up caching feature.
    |
    */
    'cache' => [
        'enabled' => false,
        'key' => 'laravel-modules',
        'lifetime' => 60,
    ],
    /*
    |--------------------------------------------------------------------------
    | Choose what laravel-modules will register as custom namespaces.
    | Setting one to false will require you to register that part
    | in your own Service Provider class.
    |--------------------------------------------------------------------------
    */
    'register' => [
        'translations' => true,
        /**
         * load files on boot or register method
         *
         * Note: boot not compatible with asgardcms
         *
         * @example boot|register
         */
        'files' => 'register',
    ],

    /*
    |--------------------------------------------------------------------------
    | Activators
    |--------------------------------------------------------------------------
    |
    | You can define new types of activators here, file, database etc. The only
    | required parameter is 'class'.
    | The file activator will store the activation status in storage/installed_modules
    */
    'activators' => [
        'file' => [
            'class' => FileActivator::class,
            'statuses-file' => base_path('modules_statuses.json'),
            'cache-key' => 'activator.installed',
            'cache-lifetime' => 604800,
        ],
    ],

    'activator' => 'file',
];
abdulrahman19 commented 4 years ago

When I run php artisan module:install --no-update abdulrahman19/test-module the problem disappear

./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Nothing to install or update

Generating optimized autoload files

> Illuminate\Foundation\ComposerScripts::postAutoloadDump

> @php artisan package:discover --ansi

Discovered Package: abdulrahman19/test-module

Discovered Package: facade/ignition
Discovered Package: fideloper/proxy

Discovered Package: laravel/tinker

Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision

Discovered Package: nunomaduro/phpinsights

Discovered Package: nwidart/laravel-modules

Package manifest generated successfully.

ocramius/package-versions:  Generating version class...

ocramius/package-versions: ...done generating version class

So I think the problem with update composer action.