box icon indicating copy to clipboard operation
box copied to clipboard

Fatal error: Cannot declare class `Composer\InstalledVersions`, because the name is already in use

Open llaville opened this issue 2 years ago • 5 comments

Bug report

Question Answer
Box version 4.3.8@5534406
PHP version 8.1.18
Platform with version Ubuntu 22.04 LTS
Github Repo -

When reusing BOX in a Composer Plugin context, PHP raise this fatal error when getting box version with \KevinGH\Box\get_box_version.

To avoid this error, I suggest to fix current get_box_version by this

if (!class_exists(InstalledVersions::class, false) && file_exists($file)) {

instead of https://github.com/box-project/box/blob/4.3.8/src/functions.php#L59

llaville avatar May 02 '23 16:05 llaville

WDYM as a composer plugin context? Installed as a regular dependency instead of a PHAR?

theofidry avatar May 09 '23 08:05 theofidry

WDYM as a composer plugin context?

My first attempt was to update declaration of box-manifest as a composer-plugin rather than a project. As box-manifest as a direct dependency to box, it lead to this error.

BTW, I've let down this approach, and I'll create a composer plugin without link to the box-project. The goal will be to create only manifest files.
Other features actually present into box-manifest willl be let down !

Installed as a regular dependency instead of a PHAR?

Yes

llaville avatar May 09 '23 09:05 llaville