PHPackages                             ocramius/package-versions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ocramius/package-versions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ocramius/package-versions
=========================

Provides efficient querying for installed package versions (no runtime IO)

2.11.0(5mo ago)3.2k74.3M—3.6%73[1 issues](https://github.com/Ocramius/PackageVersions/issues)[2 PRs](https://github.com/Ocramius/PackageVersions/pulls)20MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Jan 25Pushed 1mo ago17 watchersCompare

[ Source](https://github.com/Ocramius/PackageVersions)[ Packagist](https://packagist.org/packages/ocramius/package-versions)[ GitHub Sponsors](https://github.com/Ocramius)[ Fund](https://tidelift.com/funding/github/packagist/ocramius/package-versions)[ RSS](/packages/ocramius-package-versions/feed)WikiDiscussions 2.12.x Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (62)Used By (20)

Package Versions
================

[](#package-versions)

A message to Russian 🇷🇺 people
------------------------------

[](#a-message-to-russian--people)

If you currently live in Russia, please read [this message](./ToRussianPeople.md).

### Purpose

[](#purpose)

This utility provides quick and easy access to version information of composer dependencies.

This information is derived from the `composer.lock` file which is (re)generated during `composer install` or `composer update`.

```
$version = \PackageVersions\Versions::getVersion('ocramius/package-versions');

var_dump($version); // 1.0.0@0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
```

[![Mutation testing badge](https://camo.githubusercontent.com/69f1641136fffe418e704bdccf3473eaa320970f5fdef920fdab241340cf529c/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532464f6372616d6975732532465061636b61676556657273696f6e73253246322e302e78)](https://dashboard.stryker-mutator.io/reports/github.com/Ocramius/PackageVersions/2.0.x)[![Type Coverage](https://camo.githubusercontent.com/8ee130ed697c1a1f69842475aa7b6b5d6d3f14deb06d8777e5c7a10b2e01cf54/68747470733a2f2f73686570686572642e6465762f6769746875622f4f6372616d6975732f5061636b61676556657273696f6e732f636f7665726167652e737667)](https://shepherd.dev/github/Ocramius/PackageVersions)[![Downloads](https://camo.githubusercontent.com/434808e14d6d088fefcb267950759414cdfc17640314b5cd40e68ba0a44457b7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6372616d6975732f7061636b6167652d76657273696f6e732e737667)](https://packagist.org/packages/ocramius/package-versions)[![Packagist](https://camo.githubusercontent.com/23c429fae8ee808921cba7df4c4a98423bd48550712fbea5c7d228968f42edfb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6372616d6975732f7061636b6167652d76657273696f6e732e737667)](https://packagist.org/packages/ocramius/package-versions)[![Dependencies](https://camo.githubusercontent.com/f5e6ff552d12409e659c477b81cd043577a8b3af515eb95c414a9aae1e2e55b2/68747470733a2f2f746964656c6966742e636f6d2f6261646765732f6769746875622f7061636b61676973742f6f6372616d6975732532467061636b6167652d76657273696f6e73)](https://tidelift.com/subscription/pkg/packagist-ocramius%2Fpackage-versions?utm_source=packagist-ocramius%2Fpackage-versions&utm_medium=readme)

### Installation

[](#installation)

```
composer require ocramius/package-versions
```

It is suggested that you use [an optimized composer autoloader](https://getcomposer.org/doc/06-config.md#optimize-autoloader) (to prevent autoload I/O when accessing the `PackageVersions\Versions` API) in your composer.json:

```
...
    "config": {
        "optimize-autoloader": true
    },
...
```

In case you manually generate your autoloader via the CLI use the `--optimize` flag:

```
composer dump-autoload --optimize
```

### Use-cases

[](#use-cases)

This repository implements `PackageVersions\Versions::getVersion()` in such a way that no IO happens when calling it, because the list of package versions is compiled during composer installation.

This is especially useful when you want to generate assets/code/artifacts that are computed from the current version of a certain dependency. Doing so at runtime by checking the installed version of a package would be too expensive, and this package mitigates that.

ocramius/package-versions for enterprise
----------------------------------------

[](#ocramiuspackage-versions-for-enterprise)

Available as part of the Tidelift Subscription.

The maintainer of ocramius/package-versions and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-ocramius-package-versions?utm_source=packagist-ocramius-package-versions&utm_medium=referral&utm_campaign=enterprise&utm_term=repo).

You can also contact the maintainer at  for looking into issues related to this package in your private projects.

###  Health Score

79

—

ExcellentBetter than 100% of packages

Maintenance81

Actively maintained with recent releases

Popularity76

Solid adoption and visibility

Community47

Growing community involvement

Maturity95

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 51.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~102 days

Total

58

Last Release

57d ago

Major Versions

1.11.0 → 2.0.02020-08-21

PHP version history (14 changes)1.0.0PHP ~7.0

1.3.0PHP ^7.1.0

1.5.0PHP ^7.3.0

1.6.0PHP ^7.4.0

1.10.0PHP ^7.4.7

2.1.0PHP ^7.4.7 || ~8.0.0

2.2.0PHP ~8.0.0

2.4.0PHP ~8.0.0 || ~8.1.0

2.6.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0

2.7.0PHP ~8.1.0 || ~8.2.0

2.8.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

2.9.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

2.10.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0

2.11.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fd0445bc21fa116c259b5889377b90cbd8a34d49357321f76a74f6d2c2ae6b0c?d=identicon)[Ocramius](/maintainers/Ocramius)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (497 commits)")[![Ocramius](https://avatars.githubusercontent.com/u/154256?v=4)](https://github.com/Ocramius "Ocramius (361 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (25 commits)")[![AydinHassan](https://avatars.githubusercontent.com/u/2817002?v=4)](https://github.com/AydinHassan "AydinHassan (18 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (14 commits)")[![Jean85](https://avatars.githubusercontent.com/u/6729988?v=4)](https://github.com/Jean85 "Jean85 (10 commits)")[![kstanley-UNCC](https://avatars.githubusercontent.com/u/98065928?v=4)](https://github.com/kstanley-UNCC "kstanley-UNCC (9 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (4 commits)")[![d42ohpaz](https://avatars.githubusercontent.com/u/2528463?v=4)](https://github.com/d42ohpaz "d42ohpaz (4 commits)")[![fezfez](https://avatars.githubusercontent.com/u/1162307?v=4)](https://github.com/fezfez "fezfez (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")[![michalbundyra](https://avatars.githubusercontent.com/u/7423207?v=4)](https://github.com/michalbundyra "michalbundyra (3 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (2 commits)")[![ostrolucky](https://avatars.githubusercontent.com/u/496233?v=4)](https://github.com/ostrolucky "ostrolucky (2 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (2 commits)")[![weshooper](https://avatars.githubusercontent.com/u/2248206?v=4)](https://github.com/weshooper "weshooper (2 commits)")[![holtkamp](https://avatars.githubusercontent.com/u/776405?v=4)](https://github.com/holtkamp "holtkamp (2 commits)")[![enumag](https://avatars.githubusercontent.com/u/539462?v=4)](https://github.com/enumag "enumag (2 commits)")[![Majkl578](https://avatars.githubusercontent.com/u/144181?v=4)](https://github.com/Majkl578 "Majkl578 (2 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ocramius-package-versions/health.svg)

```
[![Health](https://phpackages.com/badges/ocramius-package-versions/health.svg)](https://phpackages.com/packages/ocramius-package-versions)
```

###  Alternatives

[ocramius/proxy-manager

A library providing utilities to generate, instantiate and generally operate with Object Proxies

5.0k82.4M230](/packages/ocramius-proxy-manager)[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[jean85/pretty-package-versions

A library to get pretty versions strings of installed dependencies

1.3k289.5M63](/packages/jean85-pretty-package-versions)[icanhazstring/composer-unused

Show unused packages by scanning your code

1.7k7.0M188](/packages/icanhazstring-composer-unused)[pocketmine/pocketmine-mp

A server software for Minecraft: Bedrock Edition written in PHP

3.5k74.6k86](/packages/pocketmine-pocketmine-mp)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
