複数バージョンのPHPを管理するツールとしてphpenvを使ってきましたが、このところアップデートの反映頻度が落ちてきて、現在PHP8.4の反映PRがマージされずに2カ月止まっている状態です。今後のアップデートも期待できそうにないため、miseへ乗り換えることにしました。
※2025/06/09追記: phpenv の更新がスピーディに実施されるようになったため、筆者は引き続き phpenv を使用しています。
mise(ミーズ)とは
mise (「ミーズ」と読みます) または「mise-en-place」は、開発環境セットアップ ツールです。この名前は、大まかに訳すと「セットアップ」または「所定の位置に置く」という意味のフランス料理のフレーズに由来しています。料理を始める前に、すべての道具と材料をその場所に用意しておく必要があるという考えです。
その機能は、以下に説明する 3 つのカテゴリに分類されます。
mise は、ノード、Python、Terraform などの開発ツール/ランタイムをインストールおよび管理します。これにより、これらのツールのインストールが簡素化され、さまざまなプロジェクトで使用するこれらのツールのバージョンを指定できるようになります。 mise は何百もの開発ツールをサポートしています。
mise は環境変数を管理し、プロジェクト間で異なる可能性がある AWS_ACCESS_KEY_ID などの設定を指定できるようにします。また、プロジェクトに入るときに Python virtualenv を自動的にアクティブにするために使用することもできます。
mise は、開発者間でプロジェクト内の共通タスクを共有し、ファイル変更時のタスクの実行などを簡単にするために使用できるタスク ランナーです。
mise-en-place About
前提条件
- Ubuntu24.04(WSL2)を使っています
- phpenvインストール済
- phpenvのインストール先は「~/.phpenv」
- 利用シェルはbash
phpenvの無効化
無効化の前に、現状の確認をしておきます。

「~/.profile」内の次の行を削除またはコメントアウトします。
export PHPENV_ROOT="${HOME}/.phpenv"
if [ -d "${PHPENV_ROOT}" ]; then
export PATH="${PHPENV_ROOT}/bin:${PATH}"
eval "$(phpenv init -)"
fi
VSCodeやターミナルを一度全て閉じてからWSL2のUbuntuのターミナルを再起動します。

aptでインストールしたPHPが適用されており、
phpenvはコマンドが見つからない状態となっています。
phpenvが全く不要な場合は、
「~/.phpenv」をフォルダごと削除して構いません。
rm -rf ~/.phpenv
※筆者はしばらく様子を見たいので、削除せずに残しておきます。
mise CLIインストール
次のコマンドでmise CLIをインストールします。
curl https://mise.run | sh

~/.local/bin/mise としてインストールされます。
バージョンを確認しておきます。
~/.local/bin/mise --version

PATHを通します。
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc

~/.bashrc への変更をシェルに反映します。
source ~/.bashrc

一応、ヘルプを確認しておきます。
$ mise --help
mise is a tool for managing runtime versions. https://github.com/jdx/mise
It's a replacement for tools like nvm, nodenv, rbenv, rvm, chruby, pyenv, etc.
that works for any language. It's also great for managing linters/tools like
jq and shellcheck.
It is inspired by asdf and uses asdf's plugin ecosystem under the hood:
https://asdf-vm.com/
Usage: mise [OPTIONS] [TASK] [COMMAND]
Commands:
activate Initializes mise in the current shell session
alias Manage aliases [aliases: a]
backends Manage backends [aliases: b]
bin-paths List all the active runtime bin paths
cache Manage the mise cache
completion Generate shell completions
config Manage config files [aliases: cfg]
deactivate Disable mise for current shell session
doctor Check mise installation for possible problems [aliases: dr]
en [experimental] starts a new shell with the mise environment built from the current configuration
env Exports env vars to activate mise a single time [aliases: e]
exec Execute a command with tool(s) set [aliases: x]
fmt Formats mise.toml
generate [experimental] Generate files for various tools/services [aliases: gen]
implode Removes mise CLI and all related data
install Install a tool version [aliases: i]
latest Gets the latest available version for a plugin
link Symlinks a tool version into mise [aliases: ln]
ls List installed and active tool versions [aliases: list]
ls-remote List runtime versions available for install.
outdated Shows outdated tool versions
plugins Manage plugins [aliases: p]
prune Delete unused versions of tools
registry List available tools to install
reshim Creates new shims based on bin paths from currently installed tools.
run Run task(s) [aliases: r]
self-update Updates mise itself.
set Set environment variables in mise.toml
settings Manage settings
shell Sets a tool version for the current session. [aliases: sh]
sync Add tool versions from external tools to mise
tasks Manage tasks [aliases: t]
tool Gets information about a tool
trust Marks a config file as trusted
uninstall Removes installed tool versions [aliases: remove, rm]
unset Remove environment variable(s) from the config file.
upgrade Upgrades outdated tools [aliases: up]
use Installs a tool and adds the version to mise.toml. [aliases: u]
version Display the version of mise [aliases: v]
watch Run task(s) and watch for changes to rerun it [aliases: w]
where Display the installation path for a tool
which Shows the path that a tool's bin points to.
help Print this message or the help of the given subcommand(s)
Arguments:
[TASK]
Task to run.
Shorthand for `mise task run <TASK>`.
Options:
-C, --cd <DIR>
Change directory before running command
-E, --env <ENV>
Set the environment for loading `mise.<ENV>.toml`
-j, --jobs <JOBS>
How many jobs to run in parallel [default: 8]
[env: MISE_JOBS=]
--raw
Read/write directly to stdin/stdout/stderr instead of by line
-y, --yes
Answer yes to all confirmation prompts
-q, --quiet
Suppress non-error messages
--silent
Suppress all task output and mise non-error messages
-v, --verbose...
Show extra output (use -vv for even more)
-h, --help
Print help (see a summary with '-h')
Examples:
$ mise install node@20.0.0 Install a specific node version
$ mise install node@20 Install a version matching a prefix
$ mise install node Install the node version defined in config
$ mise install Install all plugins/tools defined in config
$ mise install cargo:ripgrep Install something via cargo
$ mise install npm:prettier Install something via npm
$ mise use node@20 Use node-20.x in current project
$ mise use -g node@20 Use node-20.x as default
$ mise use node@latest Use latest node in current directory
$ mise up --interactive Show a menu to upgrade tools
$ mise x -- npm install `npm install` w/ config loaded into PATH
$ mise x node@20 -- node app.js `node app.js` w/ config + node-20.x on PATH
$ mise set NODE_ENV=production Set NODE_ENV=production in config
$ mise run build Run `build` tasks
$ mise watch build Run `build` tasks repeatedly when files change
$ mise settings Show settings in use
$ mise settings color=0 Disable color by modifying global config file
mise CLI アップデート
mise CLIをアップデートする場合は
mise self-update

アップデートがある場合はインストールするか確認を求められます。
現在は最新版なのでアップデートはしません。
PHPインストール
まずはインストール可能なバージョン一覧の確認をしてみます。
※同時にPHP用のプラグイン(asdf-php)がインストールされます。
mise ls-remote php

PHP用のプラグインをインストールするか訊かれるので、
[←]で「Yes」を選択して [Enter] を押します。
一瞬でインストールが終わり、PHPバージョン一覧が表示されます。

一覧の全体像がわからないので、行番号を付けて less で見てみます。
mise ls-remote php | nl | less

4.0.0からインストール可能なようです。
「>」キー(大小記号)で最終行を見てみます。

執筆時点の2024/12/30時点で8.4.2RC1まで1227個のバージョンがサポートされています。
※「q」(キュー)キーを押して less を終了します。
PHPのインストールに使うコマンドは
mise install php@[バージョン番号]
ですが、バージョン切替コマンドでもインストール可能です。
mise use php@[バージョン番号]
では、最新版の8.4.2をインストールしてみます。
mise use php@8.4.2

インストール完了後にバージョンを確認してみます。

インストール済のバージョンを確認してみます。
mise ls

※8.1.31、8.2.27、8.3.15 を追加インストールしています。
バージョン切替
miseによるバージョン切替のスコープは、
「グローバル(全体)」と「カレント(現在の)ディレクトリ」の2つです。
デフォルトはカレントディレクトリへの適用です。
「-g」オプションを使うとグローバルの適用となります。
コマンドの書式は
mise use [-g] php@[バージョン番号]
まはた
mise u [-g] php@[バージョン番号]
バージョン番号は途中までの指定でも可能です。
mise use php@8.4.2 → 8.4.2
mise use php@8.4 → インストール済の8.4.xの最新版
mise use php@8 → インストール済の8.x.xの最新版
グローバルで8.4.2を使う場合は
mise use -g php@8.4.2

特定プロジェクトで8.3.xを使う場合
mise use php@8.3

※カレントディレクトリに「.tool-versions」が作成され、ツールのバージョンが記録されます。
※ディレクトリ外ではグローバルのバージョンが適用されます。
ImagickをPHP拡張としてインストール
各PHPバージョンをインストール後に、対象のバージョンに切替をしてから
peclコマンドでPHP拡張をインストールします。
では、PHP8.4.2にimagickをインストールしてみます。
mise use php@8.4.2
pecl install imagick

途中で「Please provide the prefix of ImageMagick installation [autodetect] :」と訊かれるので、なにも入力せず [Enter] を押します。
インストール完了すると、
~/.local/share/mise/installs/php/8.4.2/lib/php/extensions/no-debug-non-zts-20240924
に imagick.so が作成されます。

が、実行権限が無いので imagick.so に実行権限を追加します。
chmod 755 ~/.local/share/mise/installs/php/8.4.2/lib/php/extensions/no-debug-non-zts-20240924/imagick.so

~/.local/share/mise/installs/php/8.4.2/conf.d/php.ini
にimagickを有効化する設定を追記します。
extension="imagick.so"
imagickが有効になっているか確認します。
php -i | grep imagick

所感
前回インストールしたvfoxとは違って、バージョンの適用が安定しているようです。
ただし、Configureオプションがvfox同様に全バージョン共通なのはどうにかならないのでしょうか?
PHPプラグインがasdf-phpなので、asdfでも同様であることが推測されます。
miseとvfoxはどうやら asdf に対抗して作られたツールのようで、
ツールの構成は類似しています。
PHP拡張は後からバージョン毎に追加ですね。
インストール可能なバージョン一覧については、ページング表示から選択してインストールできる点でvfoxの方が優れているように思います。
対応PHPバージョンはvfoxよりmiseの方が断然多いですね。
残るは asdf ですが、こちらは近々試してみようと思います。
asdfについても、次の記事の通り試してみました。
コメント