Composer - extension iconv is missing
Asked Answered
A

5

19

I'm running Manjaro linux and I have installed apache 2.4.10-1 with php 5.5.15-1 and php-composer 1.0.0.alpha8.458-1.

I want to download project with composer by this command

composer create-project nette/sandbox TaskManager

but I'm getting error with ext-iconv

- nette/neon v2.2.1 requires ext-iconv * -> the requested PHP extension iconv is missing from your system.
- nette/nette v2.2.0 requires ext-iconv * -> the requested PHP extension iconv is missing from your system.

But in my php.ini i have enabled iconv extension

extension=iconv.so
.
.
[iconv]
iconv.input_encoding = ISO-8859-1
iconv.internal_encoding = ISO-8859-1
iconv.output_encoding = ISO-8859-1

In my php scripts I can use iconv function without any problem.

When I run php -m i see iconv in list with other modules

Any idea where could be problem?

Edit: When I run php -i from cli, I got this:

Configuration File (php.ini) Path => /etc/php
Loaded Configuration File => /etc/php/php.ini
Scan this dir for additional .ini files => /etc/php/conf.d
Additional .ini files parsed => (none)

And in this config file is iconv enabled.

Even when I run

php -d error_reporting=E_ALL -r 'echo iconv("UTF-8", "ASCII//TRANSLIT", "Žluťoučký kůň\n");'

it executes properly and prints "Zlutoucky kun".

Abrasion answered 4/8, 2014 at 15:18 Comment(0)
A
24

So i found out, that composer uses different php config file, which is stored in

/usr/share/php-composer/php.ini

there I just added following line

extension=iconv.so

And everything works!

Abrasion answered 5/8, 2014 at 13:45 Comment(3)
There's a report in the Arch Linux bugtracker about this issue: bugs.archlinux.org/task/42467Annora
After reading this I found something useful and extended it. Look at this gist: composer.php.iniCrayon
but why does composer do this?Letterhead
K
12

I solved this problem uncomment the line

ext=iconv

in /etc/php/php.ini Working on manjaro linux

Krumm answered 3/2, 2019 at 20:17 Comment(2)
I try to edit in /etc/php/php.ini then uncomment extension=iconvFleurette
Worked like a charm! (arch/manjaro) - beware there was no "ext" but "extension"Pastorship
R
6

In WHM on Centos7 it worked for me.

yum install ea-php72-php-iconv

You can replace your php version instead of php72

Rabbinate answered 10/6, 2019 at 17:2 Comment(1)
Thank you, the more popular answer didn't work for me. /usr/share/php-composer/php.ini did not exist. I do think it's worth mentioning that you should use your php version ``` yum install ea-php(whatever your php version is)-php-iconv ```Wondawonder
G
3

If you are using PHPBrew run this command to install iconv extension:

phpbrew ext install iconv
Germaun answered 11/8, 2019 at 13:18 Comment(0)
A
0

I'm also running Arch (under the Manjaro stack, also using pacman.)

If the php.ini file has the correct extensions declared, but you still get the error, try the composer flag --ignore-platform-req=. In your case, probalby something like:

composer create-project nette/sandbox TaskManager --ignore-platform-req=ext-iconv

Additionally, make sure you never run composer as root, but as web, then php

su httpd -c 'php composer create-project nette/sandbox TaskManager --ignore-platform-req=ext-iconv'

If php is executing the composer command, then Composer may have a better time looking at the more relevant php.ini file.


The tendency for false alarms is arguably one more reason to not use composer when creating your own projects for others.

Bear in mind, composer was created as a kind of "nanny" to automatically install dependencies... because web admins don't know how to read the docs and do that on their own, right? It is primarily useful for web developers who don't know web admin, or are denied root access by their employers or customers, but only work higher in the stack.

Because of Composer's purpose, it may trigger a lot of false warnings. This is probably why it has the --ignore-platform-req= flag. Don't be afraid to use this as it is one of composer's redeeming qualities.

Ascent answered 23/8, 2022 at 23:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.