ext-imagick * -> the requested PHP extension imagick is missing from your system - php

I have trouble installing devisephp for laravel. I am working on the latest version of homestead with php7. when i do composer update i get the following error.
Problem 1
- Installation request for devisephp/cms 1.4.* -> satisfiable by devisephp/cms[1.4.0].
- devisephp/cms 1.4.0 requires ext-imagick * -> the requested PHP extension imagick is missing from your system.
After having this message i installed imagick on my homestead environment added the extension to php.ini in cli and fpm and checked in homestead if imagick is working with a test file. Everything was working perfectly but on running composer update i still get the same error message from above. Does anyone have a clue what the problem can be.
The stange thing is that is kan git clone devisephp its bootstrap version completely working including image handling but when i add another package to laravel i again get the above message.

if you really can't install or don't want that extension to be validated you may skip it by supplying the
--ignore-platform-reqs
flag to your composer command

Please follow these steps
sudo apt-get install php-imagick
php -m | grep imagick // this should print 'imagick' it means installed correctly
sudo service apache2 restart //(if needed)

Try adding:
"ext-imagick": "*",
to your require block in your composer.json like so:
"license": "MIT",
"require": {
"ext-imagick": "*",
....
}
and run composer update

With the config.platform key in composer.js you can fake dependencies like php versions or extensions (you can't use an asterisk for the extension version, though!)
https://getcomposer.org/doc/06-config.md#platform
As a bonus, you can polyfill ext-imagick with this library: https://github.com/calcinai/php-imagick. it's not complete and relies on the command line ImageMagick. So far it works for me.
{
"require": {
"calcinai/php-imagick": "dev-master"
},
"config": {
"platform":{
"ext-imagick": "3.4.4"
}
}
}

Related

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.22

Locally I have installed php 8
my composer.json looks like this
"require": {
"php": "^8.0",
I deleted the composer.lock and run composer install and I get the above error.
I tried to add
platform-check:false
delete composer.lock
run composer install
but then I get an error because I use Constructor property promotion in my codebase
So it seems that when I add platform-check:false, for some reason it runs on php < 8
P.S I didn't have that problem before, I just cloned my git repo and tried to run my app.
Your phpinfo() maybe having different version than 8.0. If so
Try
sudo apt-get install libapache2-mod-php8.0
Then restart your web server

when I use composer update or update new extensions, get error says verify that they are enabled in your .ini files

The error message is like this:
To enable extensions, verify that they are enabled in your .ini
files: -- - -/usr/local/etc/php/7.2/php.ini
- /usr/local/etc/php/7.2/conf.d/ext-opcache.ini
- /usr/local/etc/php/7.2/conf.d/xdebug.ini
error screenshot
I don't know how to enable this file. But when I go into that path, it exists. Can everyone help me solve that? Thanks a lot!
You need to install imagick to resolve this issue:
As per the Laravel Medialibrary requirements
The Medialibrary package requires PHP 5.5.9+ and Laravel 5.1.0+. To
create derived images GD needs to be installed on your server. If you
want to create PDF thumbnails Imagick is also required.
GD and Imagick can be installed using apt-get on Ubuntu and Debian:
$ apt-get install php-gd imagemagick php-imagick
Or with yum on CentOS:
$ yum install php70u-gd ImageMagick ImageMagick-devel
Note: Root access to your server is probably required.
OR
To resolve this add below lines in your composer.json:
{
"require": {
"spatie/laravel-medialibrary": "^7.0.0" // add this line
},
"provide": { // add this
"ext-imagick": "*" //add this
}, // add this
"require-dev": {
}
}
and run your command again
References:
https://docs.spatie.be/laravel-medialibrary/v3/requirements/#
https://github.com/spatie/laravel-medialibrary/issues/1480
https://github.com/spatie/laravel-medialibrary/issues/1553

Composer require ext-zip fails

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:
{
"require" : {
"ext-zip": "*"
}
}
Solution #2 - install php-zip extension:
Windows:
Uncomment this line in your php.ini
;extension=php_zip.dll
Linux:
sudo apt-get install php-zip
or
sudo apt-get install php7.0-zip (make sure you typed YOUR php version, you can check your version by doing php -v command)
Then, you need to restart your web server.
sudo service apache2 restart
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 as ext-apc, ext-redis and ext-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.
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 your composer.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

How to Install mbstring Extension on Heroku?

How do I install/enable PHP extension mbstring?
Heroku on its documentation says it's shared by default, and should be enabled once a Composer package require it. I tried adding it in composer.json file but nothing changed.
This is my project's composer.json:
{
"require": {
"fabpot/goutte": "^3.2",
"guzzlehttp/guzzle": "^6.2",
"paquettg/php-html-parser": "^1.7",
"ext-mbstring": "*"
}
}
After adding last dependency, I ran:
heroku run composer update
This is the error message I got:
The requested PHP extension ext-mbstring * is missing from your system. Install or enable PHP's mbstring extension.
Thank you
Heroku's filesystem is ephemeral. Any changes you make to it after your Dyno spins up can be lost at any time. This happens at least once per day, and possibly much more frequently.
Additionally, composer update is something that I would advise against running on a server. This command installs the newest available version of each library (or specific ones if you only update specific libraries) that fits what's in composer.json. If you ask for ~1.2 in composer.json you might get 1.2.1 on your development machine, but 1.2.9 in production. This can lead to some tricky bugs.
The composer install command installs the exact versions that are defined in your composer.lock file. It is much safer to run on a server, but it does mean that you've got to update your lock file locally and push it to your server.
For both of these reasons you should run composer update locally. This will update composer.lock, which should then be committed and pushed to Heroku. Heroku will run composer install, and you should be all set.
(Alternatively, you should also be able to run composer update 'ext-mbstring' to leave the rest of your dependencies alone. Be careful with composer update, and try to get in the habit of using composer install unless you know you need to update some of your dependencies.)

Deploy PHP application with extension mongo into heroku 2015

I've just deployed php application into heroku with extension mongo db.
In previous (11/2014), it's ok.
But currently I received error messsage: The requested php extension ext-mongo * is missing from your system.
Here is the structure of project on github (using to deploy into heroku):
Root
php.ini
composer.json
composer.lock
Procfile
MySources
ext
mongo.so (this file is located inside ext folder).
php.ini:
extension_dir="/app/ext/"
extension=mongo.so
composer.json:
{
"require" : {
"silex/silex": "~1.1",
"monolog/monolog": "~1.7",
"ext-mongo": "*"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
Procfile:
web: vendor/bin/heroku-php-apache2
Any one can help me to configure or sugguest me to resolve this problem? Deploy with the lasted heroku and php 5.6.7.
You don't need the ext folder (because the extension is already available on Heroku), and you don't need the php.ini, which doesn't have any effect anyway, because you're not configuring Heroku to use it.
You need to run composer update so the ext-mongo requirement gets "frozen" to composer.lock.
If you don't have that extension installed locally on your system, then you should install it (along with a MongoDB server), because you really want to test your code locally before you blindly push it up to Heroku to see whether it works or not.
If, for any reason, you can't do that, a composer update --ignore-platform-reqs will prevent "The requested php extension ext-mongo * is missing from your system" to happen on your local machine, and generate the correct composer.lock even if the extension is missing.
This is, by the way, all clearly documented here: https://devcenter.heroku.com/articles/php-support#extensions

Categories