Install and update modules
At the end, the Blog module (acme/blog) is installed and enabled in your application. Prerequisite: a module published as a package (see Publish a module as a Composer package).
Install from Composer
Section titled “Install from Composer”Composer installs packages into vendor/, so enable scanning of vendor/ first.
-
Enable scanning in
config/modules.php.config/modules.php 'scan' => ['enabled' => true,'paths' => [base_path('vendor/*/*'),],], -
Install the module with a version or constraint.
Terminal window php artisan module:install acme/blog ^1.2The command runs
composer requireand thenmodule:update. Pass a version or constraint (such as1.2.0or^1.2); without one, Composer requiresdev-master.The package suffix in StudlyCase must match the module name (
acme/blogforBlog), ormodule:installfails to find the module. -
Enable the module. Modules without an entry in
modules_statuses.jsonstart disabled.Terminal window php artisan module:enable Blog
Install from Git
Section titled “Install from Git”Pass --type to clone a module into Modules/Blog instead of vendor/.
-
Install the module from Git.
Terminal window php artisan module:install acme/blog 1.2.0 --type=github-httpsThe command clones the repository, checks out
1.2.0(a branch, tag, or commit; defaults tomaster), and runsmodule:update.--typeacceptsgithub(SSH),github-https,gitlab,bitbucket, a repository URL (https://...orfile:///...), or auser@hostSSH address. Add--path=Modules/Blogto choose another destination folder. -
Rebuild the autoloader so the merge plugin loads the module’s
composer.json.Terminal window composer dump-autoload -
Enable the module.
Terminal window php artisan module:enable Blog
To commit the module code into your application’s Git history instead of a nested clone, add --tree:
php artisan module:install acme/blog 1.2.0 --type=github-https --tree--tree adds a Git remote and runs git subtree add --squash. Your application must be a Git repository with at least one commit and no uncommitted changes to tracked files.
Install a set of modules
Section titled “Install a set of modules”List multiple modules in modules.json at the application root to install them together.
-
Create
modules.json.modules.json {"require": [{"name": "acme/blog","version": "1.2.0","type": "github-https"},{"name": "acme/shop","version": "^2.0"}]}Entries without
typeinstall from Composer. Git entries can setpathto override the target folder. -
Run
module:installwithout arguments.Terminal window php artisan module:installThe command installs each entry in order. If one entry fails, the remaining entries still run and the command exits with status
1.
See module:install for all options and error formats.
Update a module
Section titled “Update a module”Run module:update to install the Composer dependencies declared by a module.
php artisan module:update BlogThis runs composer require for the module’s require and require-dev packages and merges its scripts into the root composer.json. Use --all to update every module, or pass --no-update to module:install to skip this step.
module:update does not upgrade the module package itself. Run composer update acme/blog for a Composer module, or run git pull inside a Git module’s folder.
Check the result
Section titled “Check the result”php artisan module:listBlog appears in the list as enabled.
Related
Section titled “Related”module:installandmodule:updatemodules.jsonscan- Enable and disable modules
- Load modules from extra locations
- Autoloading and the Composer merge plugin: what the plugin merges from an installed module