PHPackages                             aklump/phpswap - 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. aklump/phpswap

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

aklump/phpswap
==============

0.0.17(2w ago)028715BSD-3-ClausePHPPHP &gt;=5.5

Since Sep 11Pushed 2w ago1 watchersCompare

[ Source](https://github.com/aklump/phpswap)[ Packagist](https://packagist.org/packages/aklump/phpswap)[ RSS](/packages/aklump-phpswap/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (18)Used By (15)

PhpSwap
=======

[](#phpswap)

[![PhpSwap](images/phpswap.jpg)](images/phpswap.jpg)

Summary
-------

[](#summary)

**PhpSwap** is a package for working with multiple PHP versions. Its CLI lets you switch between installed PHP versions by updating `PATH` in your current shell session, without changing your system-wide PHP configuration.

PhpSwap can also run automated tests across multiple PHP versions, with built-in **Composer** dependency management. Its core workflow is portable across Unix-like shells, while current provider support focuses on Homebrew and MAMP installations. PHP binaries are discovered through a pluggable provider architecture, making it easy to add support for other installation methods later.

Quick Start
-----------

[](#quick-start)

```
# Show available versions
phpswap show

# Interactively swap for the current session
phpswap --set

# Save the current PHP version for a project
phpswap --save

# Unset and return to default PHP
phpswap --unset
```

What It Does
------------

[](#what-it-does)

- Temporarily modifies `$PATH` with a different PHP version binary.
- Uses a JSON shell-action contract to safely mutate the current shell environment.
- Discovers PHP versions from multiple providers like Homebrew and MAMP.
- **Multi-PHP Testing**: Easily run your test suite across multiple PHP versions with automated Composer dependency management.

Multi-PHP Testing
-----------------

[](#multi-php-testing)

One of PhpSwap's most powerful features is the ability to test your project against multiple PHP versions. When running a command through PhpSwap, it can automatically update your Composer dependencies for the target PHP version and restore them afterwards.

```
./phpswap_execute.php using 8.1 './vendor/bin/phpunit'
```

See [Multi-PHP Testing](@testing) for more details.

### Checking for Version Support

[](#checking-for-version-support)

You can check if a version is supported before running a command:

```
if ./phpswap_execute.php supports 8.1; then
  ./phpswap_execute.php using 8.1 './vendor/bin/phpunit'
fi
```

What PHP Versions Are Supported?
--------------------------------

[](#what-php-versions-are-supported)

To see the available versions, use the `show` command.

```
phpswap show
```

Providers
---------

[](#providers)

PhpSwap discovers PHP binaries using providers. Currently supported providers:

- **Homebrew**: Discovers PHP versions installed via Homebrew formulae.
- **MAMP**: Discovers PHP versions bundled with MAMP.

Dependencies
------------

[](#dependencies)

- Bash or Zsh
- PHP (for the controller)
- (Optional) Homebrew or MAMP for managing PHP versions.

Troubleshooting
---------------

[](#troubleshooting)

Use the `diagnose` command to check if discovered PHP binaries are broken or missing dependencies.

```
phpswap diagnose
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance96

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

Every ~65 days

Recently: every ~109 days

Total

17

Last Release

18d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79476f3b82f9c766433c7eb401cbcfc636cd5d5ccf2b2e6b50ea81d1de6c2730?d=identicon)[aklump](/maintainers/aklump)

---

Top Contributors

[![aklump](https://avatars.githubusercontent.com/u/425737?v=4)](https://github.com/aklump "aklump (85 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aklump-phpswap/health.svg)

```
[![Health](https://phpackages.com/badges/aklump-phpswap/health.svg)](https://phpackages.com/packages/aklump-phpswap)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103574.3k64](/packages/friendsoftypo3-content-blocks)[phel-lang/phel-lang

Phel is a functional programming language that compiles to PHP

5196.5k21](/packages/phel-lang-phel-lang)[dagger/dagger

Dagger PHP SDK

261.4k](/packages/dagger-dagger)

PHPackages © 2026

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