Publish commands
This page lists the commands that copy files from a module to the application, and the vendor:publish tags the package registers.
Shared behaviour
Section titled “Shared behaviour”module:publish, module:publish-config, module:publish-migration, and module:publish-translation extend BaseCommand (see Contracts and base classes). They share the behaviour below; see Module management commands for details. module:publish-inertia does not extend BaseCommand.
Arguments and options
Section titled “Arguments and options”| Name | Shortcut | Default | Description |
|---|---|---|---|
module (argument) |
none | One or more module names. Optional, variadic. | |
--all |
-a |
false |
Run the action for every module. |
Module selection
Section titled “Module selection”- With names, the command runs the action once per name.
- With
--all, or withAllchosen in the interactive prompt, the command uses every module, enabled or disabled. - With no module and no interactive input, the command prints
No module given. Pass a module name or --all.and exits with1. - An unknown module name prints
Module [Nope] does not exist.(several names:Modules [Nope, Typo] do not exist.) and the command exits with1before any action runs.
Exit status
Section titled “Exit status”An action that fails does not stop the remaining modules. The command exits with 1 if the action failed for at least one module.
Existing files
Section titled “Existing files”module:publish-migration and module:publish-translation skip files that already exist at the destination. Each skipped file prints File [<path>] already exists (SKIPPED), followed by Existing files were kept. Use --force to overwrite them. Pass --force to overwrite existing files. .gitkeep files are never copied.
module:publish
Section titled “module:publish”Copies the assets of a module to the public assets path.
php artisan module:publish [<module>...] [-a|--all]Arguments
| Name | Required | Description |
|---|---|---|
module |
no | Module names. See Shared behaviour. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--all |
-a |
false |
Publish the assets of every module. |
Notes
- Source: the
assetsgenerator path of the module (paths.generator.assets.path, defaultresources/assets). - Destination:
<paths.assets>/<module name in lower case>(defaultpublic/modules/<name>). - The command always overwrites existing files. It has no
--forceoption. A module without an assets directory publishes nothing.
php artisan module:publish Blogmodule:publish-config
Section titled “module:publish-config”Publishes the configuration files of a module to the application config directory.
php artisan module:publish-config [<module>...] [-f|--force] [-a|--all]Arguments
| Name | Required | Description |
|---|---|---|
module |
no | Module names. See Shared behaviour. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--force |
-f |
false |
Overwrite config files that already exist. |
--all |
-a |
false |
Publish the config of every module. |
Notes
- The command runs
vendor:publish --provider=<provider> --tag=configfor each module. - The provider is
<modules.namespace>\<Module>\<provider namespace>\<Module>ServiceProvider. The provider namespace ispaths.generator.provider.pathwithoutpaths.app_folder, with/replaced by\. - Publishes files registered under the
configtag by that provider.ModuleServiceProviderregisters every PHP file in the moduleconfigfolder.config.phppublishes toconfig/<lowername>.php; other files publish toconfig/<lowername>/<path>.php. - Published copies override module defaults. Nested associative arrays merge key by key; lists, empty arrays
[], and scalars replace the module value as a whole. Missing keys keep the module value. See Config files.
php artisan module:publish-config Blog --forcemodule:publish-inertia
Section titled “module:publish-inertia”Publishes the Inertia app.js entry file to resources/js/app.js.
php artisan module:publish-inertia [--vue] [--react] [--svelte] [-f|--force]This command does not extend BaseCommand.
Arguments
This command has no arguments. It has no --all option.
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--vue |
false |
Publish the Vue version. | |
--react |
false |
Publish the React version. | |
--svelte |
false |
Publish the Svelte version. | |
--force |
-f |
false |
Overwrite an existing resources/js/app.js without asking. |
Notes
- The framework comes from the flag given, else
inertia.frontend(defaultvue). Pass at most one of--vue,--react, and--svelte. Passing more than one writes nothing and exits with1. The error lists options in vue, react, svelte order (for exampleThe --react and --svelte options cannot be used together. Pass only one of --vue, --react or --svelte.). This check runs before overwrite handling and is not bypassed by--force. - The stubs target Inertia v3 (
inertiajs/inertia-laravel^3 and@inertiajs/vue3,@inertiajs/react, or@inertiajs/svelte^3). Inertia v2 is not supported. - Stub:
inertia/app-vue.stub,inertia/app-react.stub, orinertia/app-svelte.stub. - The published
app.jsmounts only when<div id="app">and<script data-page="app" type="application/json">exist (rendered by@inertiaininertiajs/inertia-laravel3). Other pages skip silently. - The React stub mounts with
createRoot(el).render(createElement(App, props))fromreactandreact-dom/clientwithout JSX, because Vite parses JSX only in.jsxfiles. React pages and components stay.jsx. - The Svelte stub uses
mount(App, { target: el, props })fromsvelteand needs Svelte 5. - Only an earlier Vue
app.jsstays compatible with Inertia v3. Earlier React files contain JSX and fail to build. Republish React and Svelte with--force. - Without
--force, an existingresources/js/app.jsbehaves as follows:- Interactive: prompts
resources/js/app.js already exists. Overwrite?(default no). Answering yes overwrites, printsPublished Inertia app.js to resources/js/app.js, and exits with0. Answering no printsNothing was written. resources/js/app.js was left unchanged.and exits with1. - Non-interactive (
--no-interactionor no TTY): printsresources/js/app.js already exists. Use --force to overwrite.and exits with1.
- Interactive: prompts
- With
--force, the command overwrites the file without asking. - On success the command prints a reminder that
vite.config.jsmust includeresources/js/app.jsas an input.
php artisan module:publish-inertia --reactmodule:publish-migration
Section titled “module:publish-migration”Copies the migrations of a module to the application migration path.
php artisan module:publish-migration [<module>...] [-f|--force] [-a|--all]Arguments
| Name | Required | Description |
|---|---|---|
module |
no | Module names. See Shared behaviour. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--force |
-f |
false |
Overwrite migrations that were already published. |
--all |
-a |
false |
Publish the migrations of every module. |
Notes
- Source: the migration path of the module (
paths.generator.migration.path, ormigration.pathinmodule.json). - Destination:
paths.migration(defaultdatabase/migrations). - Files keep their names.
php artisan module:publish-migration Blogmodule:publish-translation
Section titled “module:publish-translation”Copies the language files of a module to the application lang directory.
php artisan module:publish-translation [<module>...] [-f|--force] [-a|--all]Arguments
| Name | Required | Description |
|---|---|---|
module |
no | Module names. See Shared behaviour. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--force |
-f |
false |
Overwrite translations that were already published. |
--all |
-a |
false |
Publish the translations of every module. |
Notes
- Source: the
langgenerator path of the module (paths.generator.lang.path, defaultlang). - Destination:
lang/modules/<module name in lower case>in the application.
php artisan module:publish-translation Blogvendor:publish tags
Section titled “vendor:publish tags”The package service provider registers three tags for Laravel vendor:publish. A tag is published with php artisan vendor:publish --tag=<tag>.
| Tag | Source | Destination |
|---|---|---|
config |
config/config.php of the package |
config/modules.php |
stubs |
src/Commands/stubs of the package |
stubs/nwidart-stubs |
vite |
scripts/vite-module-loader.js of the package |
vite-module-loader.js in the application root |
Notes
- Each module service provider that extends
ModuleServiceProvideralso registers aconfigtag.vendor:publish --tag=configwithout--providerpublishes the module files together with the package file. - Publishing the
stubstag does not change which stubs the generators use. Seestubs.enabledandstubs.path.
php artisan vendor:publish --tag=configvite-module-loader.js
Section titled “vite-module-loader.js”The vite tag publishes vite-module-loader.js to the application root (next to vite.config.js). Existing files are skipped unless --force is passed. For Vite configuration steps, see Compile module assets with Vite.
Exports
| Export | Signature | Returns | Description |
|---|---|---|---|
| default | async collectModuleAssetsPaths(paths, modulesPath) |
Promise<string[]> |
Reads modules_statuses.json in the application root and imports vite.config.js for each enabled module under modulesPath (relative to the loader directory). Appends each module’s paths array to paths and returns it. |
| named | moduleRefreshPaths(modulesPath = 'Modules') |
string[] |
Returns full-reload globs for every module under modulesPath, relative to the application root. |
moduleRefreshPaths() globs
Trailing slashes are stripped from modulesPath (<base>):
<base>/*/app/Livewire/**<base>/*/app/View/Components/**<base>/*/lang/**<base>/*/resources/lang/**<base>/*/resources/views/**<base>/*/routes/**
Module loading behaviour (collectModuleAssetsPaths)
| Module state | Result |
|---|---|
No vite.config.js |
Skipped silently. |
vite.config.js exports no paths array |
Skipped silently. |
vite.config.js fails to load |
Logs Skipping the assets of module <Name>: could not load <path>: <message> via console.warn and continues with remaining modules. |
Older module vite.config.js files without a paths export fail to load. Replace them with vite.stub.