Composer: How to require an alpha/beta

By Xandermar LLC, August 25, 2021

A quick tutorial that shows you how to require an alpha or beta Drupal module.

A team member tried to install and enable the module, “Media Remote Image” and had a similar issue as with Content Access. When doing so, composer was used and produced and error…

The command:

$: composer require drupal/media_entity_remote_image

Error:

[InvalidArgumentException]
Could not find a version of package drupal/media_entity_remote_image matching
your minimum-stability (stable). Require it with an explicit version constraint
allowing its desired stability.

We need to see what’s available and we can do so by running this:

composer show -a drupal/media_entity_remote_image The 'show' command will allow you to see more information and returns:

name     : drupal/media_entity_remote_image
descrip. : Media entity remote image provider.
keywords :
versions : 1.x-dev, 1.0.0-alpha2, 1.0.0-alpha1, dev-1.x
type     : drupal-module
license  : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved) https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText
homepage : https://www.drupal.org/project/media_entity_remote_image
source   : [git] https://git.drupalcode.org/project/media_entity_remote_image.git d2c6cca0a421689f793ac07ebefa6a7bc5c839e5
dist     : []
names    : drupal/media_entity_remote_image

support
source : https://git.drupalcode.org/project/media_entity_remote_image

requires
drupal/core ^8 || ^9

Looking at the versions list, let’s choose the version greater than 1.0.0-alpha2:

composer require drupal/media_entity_remote_image:^1.0.0-alpha2

Viola! It works and you’ll be able to successfully able to get the ALPHA version. Just do the same for BETA versions as well.

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing drupal/media_entity_remote_image (1.0.0-alpha2): Downloading (100%)
Writing lock file
Generating autoload files
40 packages you are using are looking for funding.
Use the 'composer fund' command to find out more!
Tags

Comments