Utility that attempts to identify what version of a given package you have installed
How to install
composer require aedart/installed-version
This package uses composer. If you do not know what that is or how it works, I recommend that you read a little about, before attempting to use this package.
use Aedart\Installed\Version\Reader; $reader = new Reader(); echo $reader->getVersion('amce/rocket-computer'); // Example output 1.22.4 ... 1.0.x-dev, or Unknown if unable to find / read package version
Reader component attempts to fetch the version from composer's
installed.json file, which should be found inside your local or global vendor.
If the reader does not find the desired package there, it will look for the
composer.json file in the current workign directory. If it matches the desired package, it attempts reading the version from it (or it's branch-alias).
Lastly, if nothing was found
Unknown is returned.
Tip: You should cache the version because "guessing" the version does come at some cost. Reading files, decoding them, looping through them...etc.
In a future version of this package, I will attempt to improve performance as well as the correctness of how to obtain the correct version number of a installed package.
If you know how to, please feel free to submit one or two pull requests.
Have you found a defect ( bug or design flaw ), or do you wish improvements? In the following sections, you might find some useful information on how you can help this project. In any case, I thank you for taking the time to help me improve this project's deliverables and overall quality.
If you are convinced that you have found a bug, then at the very least you should create a new issue. In that given issue, you should as a minimum describe the following;
- Where is the defect located
- A good, short and precise description of the defect (Why is it a defect)
- How to replicate the defect
- (A possible solution for how to resolve the defect)
When time permits it, I will review your issue and take action upon it.
Fork, code and send pull-request
A good and well written bug report can help me a lot. Nevertheless, if you can or wish to resolve the defect by yourself, here is how you can do so;
- Fork this project
- Create a new local development branch for the given defect-fix
- Write your code / changes
- Create executable test-cases (prove that your changes are solid!)
- Commit and push your changes to your fork-repository
- Send a pull-request with your changes
- Drink a Beer - you earned it :)
As soon as I receive the pull-request (and have time for it), I will review your changes and merge them into this project. If not, I will inform you why I choose not to.
- Nils Adermann & Jordi Boggiano, best thing that happened for the PHP community
This package follows Semantic Versioning 2.0.0
BSD-3-Clause, Read the LICENSE file included in this package