Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument --version does not display version #2266

Open
sljgcovas opened this issue Feb 12, 2024 · 3 comments · May be fixed by #2291
Open

Argument --version does not display version #2266

sljgcovas opened this issue Feb 12, 2024 · 3 comments · May be fixed by #2291

Comments

@sljgcovas
Copy link

For those of us that use Phinx as standalone tool, it may be convenient that --version argument actually displays the version number and not only "hey, I'm Phinx":

$ phinx --version
Phinx by CakePHP - https://phinx.org.

The --help says: -V, --version Display this application version

Thanks :)

@MasterOdin
Copy link
Member

Showing the version was removed in #1653 by @dereuromark, where I think the rationale was that updating the version field in composer.json was constantly forgotten on releases and so the info was wrong. From #1653 (comment), I do think using vendor/composer/installed.php as the easiest way to re-incorporate this without having to deal with manually incrementing a version field. Just need to also validate that this file gets packed into the phar archive as well.

@dereuromark
Copy link
Member

Could it read the version from the composer lock file etc?

@MasterOdin
Copy link
Member

MasterOdin commented Jun 5, 2024

Yeah, there's three files we could use:

  • composer.lock
  • vendor/composer/installed.json
  • vendor/composer/composer.php

The first two files have the downside of that we have to load the JSON and parse it, and then do a search through an array to find robmorgan/phinx. Additionally, for development within this repo, those files will not have a reference at all for it.

The third file has the advantage where we can just require the file and then can look up the name like $installed['versions']['robmorgan/phinx']['pretty_version'] and that it'll also have an entry for within the repo (0.x-dev) which is nice.

We could also use the composer-runtime-api to further simplify things and then could do \Composer\InstalledVersions::getPrettyVersion('robmorgan/phinx'), though this does have the downside of requiring composer 2.0+ which is probably true, though not sure it's worth mandating.

@MasterOdin MasterOdin linked a pull request Jun 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants