PHPackages                             ghostzero/semver-resolver - 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. ghostzero/semver-resolver

ActiveLibrary

ghostzero/semver-resolver
=========================

Semver Resolver written in PHP.

1.0.0(4y ago)07ISCPHPPHP ^8.0

Since Dec 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ghostzero/semver-resolver)[ Packagist](https://packagist.org/packages/ghostzero/semver-resolver)[ RSS](/packages/ghostzero-semver-resolver/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Semver Resolver for PHP
=======================

[](#semver-resolver-for-php)

Calculate an 'optimal' solution for a dependency tree using semantic versioning.

- Uses
- Which implements

> This package has unit tests with 100% code coverage.

Usage
-----

[](#usage)

```
composer require ghostzero/semver-resolver

```

```
$versionRepository = // implement version resolver
$dependencyRepository = ...; // implement dependencies repository

$resolver = new SemverResolver([
    'test1' => '^0.1.0',
    'test2' => '0.1.0'
], $versionRepository, $dependencyRepository);

$resolved = $resolver->resolve();

$this->assertEquals([
    'test1' => '0.1.1',
    'test2' => '0.1.0'
], $resolved);

```

Algorithm
---------

[](#algorithm)

The resolver works in passes. In each pass the following occurs:

1. Uncalculated dependencies are queued for calculation
2. Available versions are cached for dependencies that have not been cached yet
3. Max satisfying versions are calculated for queued dependencies
4. If constraints can't be met due to a version of a dependency fixed in an earlier pass then the version of the conflicting dependency will be backtracked to the next earlier version (by adding a new constraint), dropped from the current state of the calculation and requeued for calculation
5. Any dependencies of a requeued calculation will also be dropped and requeued
6. Calculated versions are then added to to a queue to update the state with their dependencies
7. Dependencies are cached for the calculated versions that have not yet been cached
8. The new dependencies are queued for recalculation after dropping the previous calculations and their dependencies
9. Already queued caclulations are filtered to ensure that any orphaned libraries do not get recalculated - the recursive dropping of libraries can result in already queued calculations no longer being valid/required
10. The next pass starts again at step 2

Passes continue until there are no longer any calculations queued

Limitations
-----------

[](#limitations)

Although an attempt is made to calculate an 'optimal' solution by preferring the maximum satisfying versions according to semantic versioning rules, it is possible that the actual solution could be considered sub-optimal. The following limitations should be considered.

- When backtracking it is assumed that older versions of a library will have older dependencies
    - this means we choose to backtrack the libraries providing the upper constraints
    - if a library has reverted a version of a dependency due to some issue then it may be possible that a newer matching solution could be found by backtracking the library with the lower constraint
    - in such a case, however, it may well be undesirable to backtrack and the algorithm should avoid this
- The definition of optimal may not be clear, particularly if multiple solutions are available
    - The algiorithm does not consider possible alternative solutions and only returns the first it finds
    - the choice of libraries to backtrack is somewhat arbitrary, in that on each pass the first upper constraint found will be backtracked until a solution can be found
    - It may be preferable to backtrack differently (ie. choosing different libraries to backtrack or backtracking in a different order)

If a better solution is known it should be reflected by the user through pinned versions in the root dependencies

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1616d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/03da561a330aa76d1a09096b2ee0c48ee53ca51d62fa0239469d9615b6855733?d=identicon)[ghostzero](/maintainers/ghostzero)

---

Top Contributors

[![ghostzero](https://avatars.githubusercontent.com/u/6547306?v=4)](https://github.com/ghostzero "ghostzero (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ghostzero-semver-resolver/health.svg)

```
[![Health](https://phpackages.com/badges/ghostzero-semver-resolver/health.svg)](https://phpackages.com/packages/ghostzero-semver-resolver)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k84.2M225](/packages/laravel-horizon)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)

PHPackages © 2026

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