経緯
PHP で Windows PC (Laragon 入り) のローカルにあるメールデータの件名を処理したい、と考えました。
パッケージとして php-mime-mail-parser を使おうと思ったのですが、 Composer でインストールしようとしたところ以下のエラーが発生してしまいました。
> composer require
Search for a package:
The package you required is recommended to be placed in require-dev (because it is tagged as "") but you did not use --dev.
Do you want to re-run the command with --dev? [yes]?
./composer.json has been updated
Running composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires php-mime-mail-parser/php-mime-mail-parser 9.0.1 -> satisfiable by php-mime-mail-parser/php-mime-mail-parser[9.0.1].
- php-mime-mail-parser/php-mime-mail-parser 9.0.1 requires ext-mailparse * -> it is missing from your system. Install or enable PHP's mailparse extension.
To enable extensions, verify that they are enabled in your .ini files:
- PATH\TO\LARAGON\PHP\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-mailparse` to temporarily ignore these required extensions.
Installation failed, reverting ./composer.json to its original content.
php-mime-mail-parser/php-mime-mail-parser 9.0.1 requires ext-mailparse * -> it is missing from your system. Install or enable PHP’s mailparse extension.
エラーの中から抜粋すると、 php-mime-mail-parser が依存するライブラリ (ext-mailparse
) がないのでインストールに失敗した、ということのようです。
そのため、まずはこの問題を解決することにしました。
対処
まずは上述サイトから該当の DLL をダウンロードします。

今回の環境は PHP 8.3 で 64bit 環境、スレッドセーフではないので「8.3 Non Thread Safe (NTS) x64」のリンクからzipをダウンロードします。

ダウンロードした zip を展開し、中身から php_mailparse.dll
のみ、 Laragon の PHP のフォルダ (当該 PHP のバージョンのフォルダ配下の ext
) の中へコピーします。
次に、コピーした DLL を読み込ませるために php.ini
を編集します (先の Laragon の PHP の当該 PHP のバージョンのフォルダ直下)。
; The MIBS data available in the PHP distribution must be installed.
; See https://www.php.net/manual/en/snmp.installation.php
;extension=snmp
;extension=soap
;extension=sockets
;extension=sodium
extension=sqlite3
;extension=tidy
extension=xsl
extension=zip
extension=mailparse ; この一行を追記
これでいったん Laragon のダッシュボードから Apache を再起動して、 phpinfo()
で確認。

mailparse
が読み込まれていることが確認できました。
これでもう一度 Composer でインストールをしたところ、正常にパッケージノインストールが完了しました。
……微妙に変なところで躓きましたが、標準以外のライブラリ(かつ、そのライブラリが PECL にあるならば)に依存する場合は今回と同様の対処を行う感じですかね。