composer requireで「Your requirements could not be resolved to an installable set of packages.」エラーが出たときの対処法。


問題

composer require 〇〇でパッケージをインストールしようと以下のエラーが出てインストールができない。

Using version ^1.0 for abraham/twitteroauth
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - abraham/twitteroauth 1.0.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
    - abraham/twitteroauth 1.0.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
    - Installation request for abraham/twitteroauth ^1.0 -> satisfiable by abraham/twitteroauth[1.0.0, 1.0.1].
  To enable extensions, verify that they are enabled in your .ini files:
    - C:\php-7.3.5-nts-Win32-VC15-x64\php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.

解決策

エラーの内容を見るとcurlが見当たらないことが問題らしい。

the requested PHP extension curl is missing from your system.

php.iniを開き、curlのコメントアウトを外し。有効化すればインストールが可能になる。

;extension=curl
↓
extension=curl

参考

composerで怒られた. the requested PHP extension curl is missing from your system
https://kengotakimoto.com/post-2754/