antlr / antlr-php-runtime

PHP Runtime for ANTLR4
BSD 3-Clause "New" or "Revised" License
81 stars 19 forks source link

Why is antlr/antlr-php-runtime@0.5.1 different? #20

Closed kaby76 closed 2 years ago

kaby76 commented 2 years ago

I'm trying to install version 0.5.1 of this library. I can do

composer require antlr/antlr4-php-runtime

and the package is installed.

However, if I do

composer require antlr/antlr4-php-runtime@0.5.1

I get this:

Installation failed, deleting ./composer.json.

  [RuntimeException]
  No composer.json present in the current directory (./composer.json), this may be the cause of the following exception.

  [InvalidArgumentException]
  Could not find a matching version of package antlr/antlr4-php-runtime@0.5.1. Check the package spelling, your version constraint
   and that the package is available in a stability which matches your minimum-stability (stable).

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...

In order to install the specific version, I have to:

The instructions say nothing of this, and in fact, describe using the "composer require" command, not "composer install", and do not require a composer.json file to be created. It took many hours to figure out how to work around this mess.

How do I use composer require to install 0.5.1?

Please explain.

kaby76 commented 2 years ago

The solution is here. I'm not sure where I read the syntax with the "@"-sign, but it is wrong. The right code is:

composer require antlr/antlr4-php-runtime:0.5.1
# or
composer require antlr/antlr4-php-runtime:0.5.0
# or
composer require antlr/antlr4-php-runtime:0.6.0

Nevertheless, it should be explained in the readme.md, especially for a specific branch, e.g., 4.9.3 of the Antlr tool is incompatible with version 0.6.0 of antlr/antlr-php-runtime, so the instructions are wrong. Small details really matter.