Skip to content

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).

Composer installs packages into vendor/, so enable scanning of vendor/ first.

  1. Enable scanning in config/modules.php.

    config/modules.php
    'scan' => [
    'enabled' => true,
    'paths' => [
    base_path('vendor/*/*'),
    ],
    ],
  2. Install the module with a version or constraint.

    Terminal window
    php artisan module:install acme/blog ^1.2

    The command runs composer require and then module:update. Pass a version or constraint (such as 1.2.0 or ^1.2); without one, Composer requires dev-master.

    The package suffix in StudlyCase must match the module name (acme/blog for Blog), or module:install fails to find the module.

  3. Enable the module. Modules without an entry in modules_statuses.json start disabled.

    Terminal window
    php artisan module:enable Blog

Pass --type to clone a module into Modules/Blog instead of vendor/.

  1. Install the module from Git.

    Terminal window
    php artisan module:install acme/blog 1.2.0 --type=github-https

    The command clones the repository, checks out 1.2.0 (a branch, tag, or commit; defaults to master), and runs module:update.

    --type accepts github (SSH), github-https, gitlab, bitbucket, a repository URL (https://... or file:///...), or a user@host SSH address. Add --path=Modules/Blog to choose another destination folder.

  2. Rebuild the autoloader so the merge plugin loads the module’s composer.json.

    Terminal window
    composer dump-autoload
  3. 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:

Terminal window
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.

List multiple modules in modules.json at the application root to install them together.

  1. Create modules.json.

    modules.json
    {
    "require": [
    {
    "name": "acme/blog",
    "version": "1.2.0",
    "type": "github-https"
    },
    {
    "name": "acme/shop",
    "version": "^2.0"
    }
    ]
    }

    Entries without type install from Composer. Git entries can set path to override the target folder.

  2. Run module:install without arguments.

    Terminal window
    php artisan module:install

    The 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.

Run module:update to install the Composer dependencies declared by a module.

Terminal window
php artisan module:update Blog

This 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.

Terminal window
php artisan module:list

Blog appears in the list as enabled.