Introduction to Composer Commands in Flarum and Detailed Usage

6,653 0

The installation method officially recommended by Flarum is to use Composer. You can Google or Baidu a tutorial on installing Composer. Both LNMP and LAMP come with it, so they will not be discussed here. If you find that Composer updates are slow, fail, or even produce errors when setting up a local or mainland China server, you can use a domestic mirror.

Bash
sudo composer config -g repo.packagist composer https://packagist.phpcomposer.com

After entering the command, simply run composer update to use the domestic mirror.

Common Composer Commands

Using the plugin flagrow/ads as an example:

Install a plugin

Bash
composer require flagrow/ads

Remove a plugin

Bash
composer remove flagrow/ads

Update a plugin

Bash
composer update flagrow/ads

Running composer update in the Flarum root directory updates the entire Flarum package, including plugins.

Specify a Version When Installing a Plugin

Using the plugin flagrow/upload as an example:

Bash
composer require flagrow/upload:0.4.13

You can also use the following command to update within a major version:

Bash
composer require flagrow/upload:0.4.*

If you need to install the latest development version:

Bash
composer require flagrow/upload:dev-master

If you want to install the official Flarum development version (dev), here is one recommended method:

After installing the beta version, modify the composer.json file in the root directory.

Change the flarum/core version in it to "flarum/core": "0.1.x-dev".

Then replace all the flarum/flarum-ext-**** versions with dev-master.

That is, batch-replace ^0.1.0 with dev-master.

Finally, run composer update to update to the dev version.

Comments

(0)

No comments yet. Start the conversation.

Leave a comment