Skip to content
Sami Mazouz edited this page Oct 31, 2021 · 9 revisions

This contains an explanation of how the package manager works and what it has to offer.

Features

Requirements

There are some obstacles that need to be taken care of before this can be used.

File Permissions

The relevant machine web user needs to have permissions to read and write to: vendor, composer.json, composer.lock and storage. Right now a warning shows up when this is not the case, this should preferably be changed to mention only the files/dirs where permissions are lacking instead of all of them.

flarum lan_admin (3)

Path Repository

In development environments (and production in rare scenarios) there should a path repository to a directory containing (mostly dev) packages, the path to this directory must be changed to an absolute path otherwise composer will have trouble running any command. Additionally the path repository by default has higher priority, so requiring an extension that exists in that repository will probably fail, unless a *@dev constraint is specified, in which case the package manager should not be used for dev purposes anyway.

There is currently now hint of any of this in the package manager UI.

Common Actions

Each one of the features listed above is basically a composer command or two, and there are common actions/common behaviour between them all.

  • Restricting access to the admin.
  • Validating the provided package name or the extension id if given.
  • Erroring out if installing an existing extension, updating or removing a non existing extension ...etc
  • Running the command.
  • Logging the output.
  • Erroring out on command failure.
  • Updating the last update check.
  • Dispatching an event.
  • If running an update:
    • Clear Cache.
    • Run Migrations.
    • Publish Assets.

Command Output Logging

Considering this is still experimental and for the sake of easier support, each command output is logged to storage/logs/composer just like the flarum error logs, allowing to go back and see what happened during a command execution.

Command Failure

When a composer command fails (recognised by the exit code), an exception is thrown containing the output of the command which is displayed through a modal in the UI. With certain command failures, we try to guess the reason, for example trying to install an incompatible extension will fail with a specific output message, which we can currently guess and display along side the output as an error in the modal.

Screenshot from 2021-09-29 14-26-37

Checking for Updates

This executes the command composer outdated -D --format json which checks for updates of packages directly required in the root composer.json and outputs the results in JSON format. Only packages marked as semver-safe-update and update-possible by composer are displayed.

flarum lan_admin (4)

Patch-Minor Flarum Updates

This executes the command command update flarum/* --prefer-dist --no-dev -a --with-all-dependencies, updating flarum core and its bundled extensions to the next minor or patch release. Bundled extensions can of course still be separately updated just as normal extensions.

flarum lan_admin (5)

Global Updates

Runs the command command update --prefer-dist --no-dev -a --with-all-dependencies, useful for updating all packages.

Major Updates

Remains untested.

major update UI

TODO

https://github.com/flarum/package-manager/issues

Clone this wiki locally