I am told by PHPStorm that I need to composer require ext-zip, however, that command is failing...
PHPStorm says
The command I am issuing is
composer require ext-zip
results in
Your requirements could not be resolved to an installable set of packages.
and
Installation failed, reverting ./composer.json to its original content.
Solution #1 - add ext-zip to your required section of composer.json:
Solution #2 - install php-zip extension:
Windows:
Uncomment this line in your php.ini
Linux:
or
Then, you need to restart your web server.
The given hint comes from PhpStorm, not from composer itself: your IDE has detected that your code uses a method (or in this case: the
ZipArchive
class) that is only available when the ZIP extension is enabled. But yourcomposer.json
did not contain that requirement so far.So, PhpStorm asks you to add this requirement to the JSON file to make the requirements to run your code more precise. How you solve that requirement is up to you: the best way would be to install that extension, but that is out of composer's scope
If your code runs OK - you've already got the zip extension installed on your machine. PHPStorm adds this suggestion to ensure that anywhere else that the project is deployed also has the right extensions too.
Manually adding the line in your composer.json file (
require
block)"ext-zip": "*",
(and others that it can suggest, such asext-apc
,ext-redis
andext-json
, as well as any others that you might be using) will make sure that when you deploy it composer can also check that the appropriate extra items are installed.It's only a warning though, and you could ignore it - or you can allow composer to make sure that your servers are setup as they would be needed to run your code, and do things with zip-files. If your server doesn't have ext-zip installed,
composer install
would complain, and stop - saving issues later when you discover that code fails without the zip extension, et al.