PHPackages                             webit-de/php-version-pickup - 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. webit-de/php-version-pickup

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

webit-de/php-version-pickup
===========================

Set a PHP version used in a shell session through a `.php-version` file

1.3.0(4y ago)31.7k—0%1[1 PRs](https://github.com/webit-de/php-version-pickup/pulls)GPL-2.0-or-laterShell

Since Jan 31Pushed 4y ago2 watchersCompare

[ Source](https://github.com/webit-de/php-version-pickup)[ Packagist](https://packagist.org/packages/webit-de/php-version-pickup)[ RSS](/packages/webit-de-php-version-pickup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

PHP Version Pickup
==================

[](#php-version-pickup)

Set a PHP version used in a shell session through a `.php-version` file.

[![Packagist](https://camo.githubusercontent.com/5b4a9306cffac9d1717f8f2ca1d27f526b24bf4fcb13d152a67815319d204f9c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656269742d64652f7068702d76657273696f6e2d7069636b75702e737667)](https://packagist.org/packages/webit-de/php-version-pickup/)[![Made With](https://camo.githubusercontent.com/ab41a762805518ccd1f93659b306e69095a147f4da68bfa8455f6ed7e9b80396/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f245f5f2d626173682d626c61636b)](https://gitlab.com/webit-de/php-version-pickup#requirements)[![License](https://camo.githubusercontent.com/b496089b000321476dec7444dfdcbbc2acc81bd42bc28f7b527f74fdd0083df8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d67706c2d2d322e302d2d6f722d2d6c617465722d626c75652e737667)](https://spdx.org/licenses/GPL-2.0-or-later.html)

[![screenshot](./docs/screenshot.png)](./docs/screenshot.png)

Vision
------

[](#vision)

This tool is a small shell script to set the version of PHP used in a shell session, by reading the expected version number from a `.php-version` file.

This allows to handle multiple PHP versions in a local development environment and switch the version between projects on the fly. By pinning the version in a file it also allows team members to use same PHP version when working on a project.

The script is inspired by [`nvm use`](https://github.com/nvm-sh/nvm#nvmrc) and [`php-version`](https://github.com/wilmoore/php-version). The former is made for Node and does a lot more (build &amp; install versions etc.). The letter works perfectly well with PHP, but does not want to store files nor support PHP versions installed by the OS package manager. That's why this script was created.

The file `.php-version` is already used by popular PHP packages like [Symfony Server](https://symfony.com/doc/current/setup/symfony_server.html#selecting-a-different-php-version).

**Key Features**

- Set a PHP version for a shell session only (forget version in new shells, don't mangle system defaults)
- [Pass the version to subscripts as well](https://pixelbrackets.de/notes/pass-php-version-to-subscripts-in-cli-calls)(run Composer with the selected version, Composer passes the version to other executed PHP scripts as well)
- Pick up the version from a `.php-version` file
- Support PHP versions installed via PPA
- Written in Bash, to pick versions before running PHP scripts
- Does not attempt to manage version used by the OS or webserver (Apache, Nginx)

**Current limitations** *✨ Feel free to send a PR to resolve them✨*

- Mayor PHP version numbers only (`7.3`, `7.4`, no `7.3.10`)
- No `latest` version etc.
- No installation of missing versions
- No automatic execution (`cd` hook)
- No display of locally available versions
- No display of remote available versions (all PHP version releases)

Requirements
------------

[](#requirements)

- PHP (the script picks up existing PHP versions, it runs without PHP however as it is a shell script)

Installation
------------

[](#installation)

- Clone the repository

    ```
    cd ~/
    git clone https://github.com/webit-de/php-version-pickup.git .php-version-pickup
    ```
- »Source« the script

    ```
    echo 'source $HOME/.php-version-pickup/bin/php-version-pickup.sh' >> $HOME/.bashrc
    ```

    *or* add the line manually to your `.bashrc` file

    ```
    source $HOME/.php-version-pickup/bin/php-version-pickup.sh # or your place of choice
    ```
- 🏗️ Install multiple PHP versions (build manually, use the great [PPA by Ondřej Surý](https://launchpad.net/~ondrej/+archive/ubuntu/php), or use a tool like [php-build](https://github.com/php-build/php-build) or [homebrew-php](https://github.com/josegonzalez/homebrew-php))
- Create symlinks pointing the PHP versions locally available

    This depends very much on the way you installed the multiple PHP versions. The general structure of each symlink is `$HOME/.php/versions//bin/php -> `

    The following example assumes you installed three versions via Ondřejs PPA. *Adapt this to your own setup*.

    ```
    mkdir -p $HOME/.php/versions/7.3/bin && ln -s /usr/bin/php7.3 $HOME/.php/versions/7.3/bin/php
    mkdir -p $HOME/.php/versions/7.4/bin && ln -s /usr/bin/php7.4 $HOME/.php/versions/7.4/bin/php
    mkdir -p $HOME/.php/versions/8.0/bin && ln -s /usr/bin/php8.0 $HOME/.php/versions/8.0/bin/php
    ```
- 💡 You may want to add an alias as shortcut command to your `.bashrc` like `alias pvm="php-version-pickup"`

Source
------

[](#source)

Usage
-----

[](#usage)

The script reads the version from a file.

**Create a version file in your project of choice**

⚠ Right now only [mayor PHP release numbers](https://www.php.net/supported-versions) are allowed, which means something like `7.4` or `8.1` (not a specific version like `7.4.10`).

Example to set PHP version 7.4 in a project:

```
php-version-pickup set 7.4
```

(This is the same as running `echo "7.4" > .php-version` manually).

**Pick up the version**

Run `php-version-pickup use` in your directory to pick up the version number. You should see a message telling you that a file was found and which version is used in your shell session from now on.

Run `php --version` to check the version.

Now you can run PHP scripts, Composer, whatever with the set version.

🥏 Play around with the version file, open and close shells, run some PHP scripts and make yourself comfortable with this simple version picker.

**Provide feedback**

This script is a prototype and helped us in a very specific use case. Therefore, some limitations exists (see [vision](#vision)). Feel free to send some feedback or create a PR to enhance this script.

License
-------

[](#license)

GNU General Public License version 2 or later

The GNU General Public License can be found at .

Author
------

[](#author)

Dan Untenzu ( / [@pixelbrackets](https://github.com/pixelbrackets)) for webit! Gesellschaft für neue Medien mbH ()

Changelog
---------

[](#changelog)

See [CHANGELOG](./CHANGELOG.md)

Contribution
------------

[](#contribution)

> TYPO3 - inspiring people to share!

This package is Open Source, so please use, patch, extend or fork it.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

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

Every ~16 days

Total

4

Last Release

1519d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ca67c6c7d79cf33bb5688dcbf217ad52309a52580b6a490aae8445f446178a3?d=identicon)[pixelbrackets](/maintainers/pixelbrackets)

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

---

Top Contributors

[![pixelbrackets](https://avatars.githubusercontent.com/u/1592995?v=4)](https://github.com/pixelbrackets "pixelbrackets (13 commits)")

### Embed Badge

![Health badge](/badges/webit-de-php-version-pickup/health.svg)

```
[![Health](https://phpackages.com/badges/webit-de-php-version-pickup/health.svg)](https://phpackages.com/packages/webit-de-php-version-pickup)
```

PHPackages © 2026

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