laravel-modules icon indicating copy to clipboard operation
laravel-modules copied to clipboard

How can i Vendor:publish in a module

Open redtusker opened this issue 1 year ago • 5 comments

unable to vendor publish config and assets and there is no command way to do so

i.e want to run the following but its not working there is no commands for module to do so

php artisan vendor:publish --provider="Spatie\WebhookServer\WebhookServerServiceProvider"

redtusker avatar Sep 13 '24 18:09 redtusker

Hi,

To publish configuration files, you can use the following command:

php artisan module:publish-config

To publish assets, use this command:

php artisan module:publish

Both commands support the --all option to publish for all modules. You can also specify multiple module names like this:

php artisan module:publish-config Base User Tag

for publish package config,vite-loader and stubs :

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

alissn avatar Sep 13 '24 18:09 alissn

Hi, thanks for replying

I tried those commands but it didn't work the config and migrations are not published

image

redtusker avatar Sep 13 '24 19:09 redtusker

ensure you module contain this function on provider and call on boot method. and path is correct.

    /**
     * Register config.
     */
    protected function registerConfig(): void
    {
        $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
        $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
    }

reference on module sutb: https://github.com/nWidart/laravel-modules/blob/15dec6bed2826feba9012a59bf08f880ecc9ba7d/src/Commands/stubs/scaffold/provider.stub#L74-L81

alissn avatar Sep 13 '24 19:09 alissn

Yes the module contain this function on the provider

protected function registerConfig(): void
   {
       $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
       $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
   }

redtusker avatar Sep 13 '24 23:09 redtusker

but still its not working as expected and still unable to publish those files

redtusker avatar Sep 14 '24 16:09 redtusker

identified the problem, applied a fix, will be doing a release shortly.

dcblogdev avatar Nov 16 '24 14:11 dcblogdev