Unable to install composer globally on Cygwin - php

When I run the this command 'php -r "readfile('https://getcomposer.org/installer');" | php' on Cygwin terminal. The following errors have been triggered on the terminal:
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The json extension is missing.
Install it or recompile php without --disable-json
The phar extension is missing.
Install it or recompile php without --disable-phar
The iconv OR mbstring extension is required and both are missing.
Install either of them or recompile php without --disable-iconv
However, all these extensions are enabled in php.ini file. I am using XAMPP.

I think you need to install the correct php extensions ...
apt-cyg install \
php \
php-json \
php-phar \
php-mysql \
php-curl \
php-gd \
php-intl \
php-imap \
php-mcrypt \
php-pspell \
php-recode \
php-tidy \
php-xmlrpc \
php-xsl
PS: I created a install-script for this :) https://github.com/voku/dotfiles/blob/master/firstInstallCygwin.sh

Related

install XMLReader module extension ubuntu

Im working with a plugin that requires XMLReader, and XMLWriter PHP modules to be installed. So I need to activate the DOMDocument, XMLReader, and XMLWriter PHP modules.
So far i have tried :
sudo apt install php-xmlwriter
apparently is installed but the message still is displayed. Am i missing something else? another module?
For PHP 7.4 There is no php7-xmlreader or php7-xmlwriter package shown using apt-list. Only php7.4-xml and php7.4-xmlrpc - installing these/restarting apache and running php -m shows that xml support (including reader/writer) is enabled.
sudo apt-get update && apt list php7*
sudo apt install -y php7.4-xml php7.4-xmlrpc
sudo service apache2 restart
php -m
I finally came to a simple answer for this. Just needed to install the following:
sudo apt install php7.3-xml and this included both modules needed.
You just need to install each xml extension: php7-xml, php7-xmlreader and php7-xmlwriter
Here is an example
apk add --update --no-cache \
php7 \
... HERE ARE OTHER EXTENSIONS ...
php7-xmlwriter \
php7-xmlreader

PHP intl extension in Docker container

I'm trying to load the intl PHP extension in my Docker container, but it doesn't seem to work.
Have already tried this https://github.com/docker-library/php/issues/57 but I still get the same error message:
configure: error: in `/usr/src/php/ext/intl':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
My Docker file looks like this:
RUN apt-get -y update \
&& apt-get install -y libicu-dev\
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
and it's loading from php:fpm
Have anyone gone through this and got to solve the problem? It's getting me nuts.
Your code worked perfectly for me once I added a space before the backslash terminating the second line of the run command:
RUN apt-get -y update \
&& apt-get install -y libicu-dev \ ### <-- Added space here
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
It seems some requirements are missing. The snippet below worked for me:
ARG PHP_VERSION=5.6
FROM php:${PHP_VERSION}-fpm-jessie
apt-get install -y zlib1g-dev libicu-dev g++ \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
Unfortunately, some php extensions have dependencies to other programs. There is a project called docker-php-extension-installer that you can use to install PHP extensions. It will make sure that the required dependencies are present as well. See https://stackoverflow.com/a/56224300/413531 for an example how I actually integrate it in a Dockerfile.
For older build scripts, this problem may be caused by icu-devtools recently dropping icu-config. On debian, it can be fixed by downgrading libicu-dev and icu-devtools:
apt-get install libicu-dev=57.1-6+deb9u4 icu-devtools=57.1-6+deb9u4
To determine the specific version that may work for you, just do:
apt-cache policy libicu-dev
And choose a version up to ~60. Same for icu-devtools.
I found this problem while trying to build a docker image for PHP 7.1. For more context, check debian bug report 920900.

PHP7 fails to load memcached and redis on Alpine docker container

I'm trying to create a Docker image based on Alpine Linux which will run PHP 7.1 (apk add php7=7.1.9-r0) with some modules installed (memcached, mongodb, oauth, openssl and redis).
I install the modules through PECL like this:
RUN yes | pecl install \
igbinary \
redis-3.1.4 \
oauth-2.0.2 \
memcached-3.0.4 \
mongodb-1.3.3
Then add each of them to php.ini.
RUN for EXT in \
igbinary \
memcached \
mongodb \
oauth \
openssl \
redis; \
do \
echo "extension=${EXT}.so" >> /etc/php7/php.ini; \
done
Most modules install correctly, but memcached and redis don't want to play along:
# php -v
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php7/modules/memcached.so' - Error relocating /usr/lib/php7/modules/memcached.so: php_session_create_id: symbol not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php7/modules/redis.so' - Error relocating /usr/lib/php7/modules/redis.so: php_session_register_module: symbol not found in Unknown on line 0
PHP Warning: Module 'openssl' already loaded in Unknown on line 0
PHP Warning: Cannot load module 'mongodb' because required module 'json' is not loaded in Unknown on line 0
PHP 7.1.9 (cli) (built: Oct 2 2017 20:51:54) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
I've also tried from source:
RUN git clone https://github.com/php-memcached-dev/php-memcached
RUN cd php-memcached \
&& git checkout php7 \
&& git pull \
&& /usr/bin/phpize \
&& ./configure --with-php-config=/usr/bin/php-config \
&& make \
&& make install
This however gives me the same result. I've done some searching and apparently there might be some related problem of glibc on Alpine (example thread) but I'm not quite sure this is the same issue as the error output is a bit confusing.
Is there anything I'm overlooking as to how these modules should be installed to work with PHP 7.1 on Alpine Linux?
All of these extensions are available in Alpine repositories, so why are you making your life harder and installs them directly from PECL? Install them simply using apk.
php7-redis
php7-oauth
php7-memcached
php7-mongodb (currently only in testing repository)
php7-openssl
Note that these packages are in Alpine v3.7 (the latest stable release), I haven’t checked if they are available also in older releases.
These packages, of course, installs config files with extension=<ext>.so, so don’t add it manually to php.ini.
apk add php7=7.1.9-r0
Why do you specify exact version? This will fail once we update the package (e.g. with security patches), because only the latest version of packages is available in the repositories. We backport only security fixes and bugfixes (i.e. patch versions) into stable releases, so there will not be 7.2.x in v3.6 or v3.7.
PHP 7.2 And onward are based on Alpine 3.7 Wich has all the necessary extensions available in the repository.
However there are PHP 7.1 and PHP 7.0 Which are still based on 3.4 which does not have any php7-* extensions.
Workaround is to install pecl and which in turn can install all necessary extensions.
You can achieve this in this way:
RUN apk update\
&& apk upgrade \
&& apk add libmemcached \
libmemcached-libs \
libmemcached-dev \
build-base \
zlib-dev \
php5-dev \
git \
autoconf \
cyrus-sasl-dev \
&& pecl config-set php_ini /usr/local/etc/php/php.ini \
&& pecl install -f memcached \ #Add any Additional packages
&& echo extension=memcached.so >> /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini \
&& rm -rf /tmp/pear \
&& apk del php5-dev \
build-base \
zlib-dev \
php5-dev \
git \
autoconf \
cyrus-sasl-dev
This will install PECL with php5 which works perfectly to install extensions for PHP 7+
And dont forget to include your packages
We were facing similar issues with the "official" PHP images build on Alpine. Ie. it was impossible for us to install a working ImageMagick version in PHP 7.1 which is based on Alpine 3.4
What we did is installing it from Alpine 3.6, while I actually won't recommend this it might be a workaround.
The other workaround is to wait for PHP 7.2 which is build on Alpine 3.6. Might be an option to look for a working PHP + Alpine combination, since you are building FROM alpine and not FROM php:alpine
Just saying: Issues like that made us go back to Debian images, since we've wasted tons of hours on that, including weird glibc issues like you mentioned.

Composer doesn't see GD extension

I've installed GD on Docker machine as described in https://hub.docker.com/_/php/ using:
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
for both PHP 7 and PHP 5.6. It's working without a problem (I can manipulate images) but I want to now install some composer package that requires "ext-gd": "*", and the problem is like this:
php -m
shows gd loaded but
composer show -p
doesn't show ext-gd so I cannot install package I need using composer. Is there any way to install GD to make Composer see it?
I've found similar issue here: https://github.com/composer/composer/issues/4353 but it was closed without resolving. Also composer dependency stating in dont have php-xsl wasn't solved.
For reference I've verified also Homestead and there composer show -p shows ext-gd without a problem also on my localhost (Windows) it's working.
So the only problem I found is with Docker installation. Do you have any clue how can it be solved?
The problem was not directly of Composer but the way I used it.
I had Composer installed in /usr/local/bin/composer but created alias like so:
alias composer="php -n /usr/local/bin/composer"
to not use Xdebug when running composer.
But in fact it was causing all PHP extensions were disabled when running composer so when composer tried to install any package requiring GD2 it didn't see GD2 was installed.

linux php 7 configure: error: Please reinstall readline - I cannot find readline.h, but it is installed

I am compiling php7 from source and have pre compiled a number of dependencies in /home/mybin for example I have openssl in
/home/mybin/bin/openssl
/home/mybin/include/openssl/*.h
I have also readline as
/home/mybin/include/readline/readline.h
using the php compile options
./configure \
CC=/home/mybin/bin/gcc \
--prefix=/home/_cgi/php7 \
--bindir=/home/mybin/bin \
--libdir=/home/mybin/lib \
--with-libdir=/home/mybin/lib64 \
--includedir=/home/mybin/include \
--include-openssl \
i have tried the following options for readline
--with-readline=/home/mybin/include/readline
OR
--with-readline=/home/mybin/
OR
--with-readline
all variations end with configure: error: Please reinstall readline - I cannot find readline.h
All other dependencies built from source and in /home/mybin are found no problem. Can you suggest what flag I sould set so readline.h can be found?
thx Art
On Debian-9 first, I installed libreadline-dev package using
apt-get install libreadline-dev
and then when searching for the path of readline.h using command
dpkg -S readline.h
It gave me below output:
nodejs: /usr/share/doc/nodejs/api/readline.html
libreadline-dev:amd64: /usr/include/readline/readline.h
So the file is located in /usr directory
Finally I configured php using --with-readline=/usr and everything was fine.
for readline you need to install
sudo apt install -y libedit-dev libreadline-dev
please see http://stackoverflow.com/questions/35891777/linux-correct-flag-to-pass-gcc-mcrypt-h-location for a good description of how to fix this issue as both are related

Categories