How can I install PHP extensions to satisfy composer? - php

I am creating a app and am trying to install a library into my project though composer.
Composer has given me the error:
Problem 1
- The requested PHP extension ext-gmp * is missing from your system. Install or enable PHP's gmp extension.
Ok, it seems like I need to gmp extension.
I am using a Mac, and using a local test server with XAMPP.
Now this is where it starts getting confusing. I went to my XAMPP php.ini and remove the ";" from gmp extension like this:
xampp attempt
I retried composer installation with no luck. My next thought was that the extension needs to be installed on the global PHP Mac installation... I removed the ";" for gmp on that php.ini, but no luck. How can I solve this?

-if you need it for php 5 use
brew install homebrew/php/php55-gmp
-if you need it for php 7 use
brew install homebrew/php/php70-gmp
-and if you don't have homebrew, you can install it using this command
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
OR you can jsut run
brew install php#7.1
since it have all the packages you need for php 7.1

Related

Install MongoDB PHP Extension for PHP 8.1 (Debian)

sorry if there is a duplicate question for this but I'm trying to set this up for hours now and it just doesn't work.
I have a Debian 11 server with "KeyHelp" installed on it (little brother of plesk). It comes with PHP 7.4 but provides a simple Dashboard where you can install other PHP versions. I installed PHP 8.1 and tried to install the mongodb extension via PECL.
After "pecl install mongodb" I added "extension=mongodb.so" and after that didn't show up the extension on the phpinfo page, I double checked if the extension is really in the extension folder of php, where it was.
Turns out that I installed the extension for PHP 7.4 and not for PHP 8.1. Finally I tried to force PECL to install it for PHP 8.1 but it says "phpize8.1 command not found". I found no way to install phpize8.1, can somebody help me out with that?
Thanks in advance!
I am using Ubuntu 20.04
I have PHP 8.1 version. You have to install modules of PHP
sudo apt install php8.1-mongodb
List the modules
php -m
It's not exactly Debian. I hope it helps you.
If you run command:
sudo apt install php-dev
System will install automatically the correct version of php{x}-dev for your distribution, and all it's dependencies, included PECL.
another way is try to run:
/usr/bin/phpize
If this command works, you need to add phpize to your PATH:
PATH=$PATH\:/usr/bin; export PATH
In this way phpize will work in future.

PECL install with --configureoptions not working - Memcache

Lately, I have been trying to install the pecl memcache PHP extension on OSX Catalina with brew memcached installed and I'm getting the following error every time I try the install process:
configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
I have tried with pecl install memcache and with pecl install --configureoptions='with-zlib-dir="path"' memcache to no avail. It always gets the same point and it fails.
From what I have reviewed on different topics regarding the installation of the package the issue seems to be with the -D option in the pecl install command, because when I do a manual install from the source code passing the argument --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11 to the ./configure command it works like a charm and installs the package but is now not listed in pecl list installed packages and as so it cannot be uninstalled.
The issue is I need pecl to manage the installation of the package to be able to uninstall it any time when the environment changes from project to protect.
A quick fix for this (found via https://bugs.php.net/bug.php?id=56522) is to use the PHP_ZLIB_DIR variable instead of --with-zlib-dir.
i.e. PHP_ZLIB_DIR=/usr/local/Cellar/zlib/1.2.11 pecl install memcache
I've struggled with the -D option before as well - near as I can tell it's completely broken.

Can not connect to MongoDB from PHP

I have installed MongoDB PHP lib
but despite this I can't connect to MongoDB database
Error of rockmonogo :
To make things right, you must install php_mongo module. Here for installation documents on PHP.net.
Error of phpmoadmin :
PHP cannot access MongoDB, you need to install the Mongo extension for PHP.
Error of Laravel with Jenssegers\Mongodb lib :
Unsupported driver [mongodb]
Make sure that it is in fact properly installed. The errors you're getting seem to indicate that your environment can't find the extension. I've compiled installation instructions for you.
Unix-like Systems
Open a terminal emulator and run wget http://pear.php.net/go-pear.phar
Then start the installation of PECL with php go-pear.phar
Install the PHP MongoDB extension sudo pecl install mongodb.
Add extension=mongodb.so to the php.ini file.
Mac OS X
Install homebrew by running /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" in a terminal.
Run brew update
Run brew tap homebrew/php
Install the extension according to your PHP version.
PHP 5.4: brew install php54-mongodb
PHP 5.5: brew install php55-mongodb
PHP 5.6: brew install php56-mongodb
PHP 7.0: brew install php70-mongodb
Windows
Open your web browser to http://pecl.php.net/package/mongodb
Open the latest version from the DLL link (with the Windows icon).
Choose the appropriate version from the DLL list. They are sorted by PHP version, system architecture (i.e. 32-bit vs 64-bit), and thread safety.
Extract the downloaded archive and place php_mongodb.dll in your PHP extensions directory.
Add extension=php_mongodb.dll to the php.ini file.
For mac system, the homebrew php tap mechanism is deprecated and it won't work. You need to manually install it or you need to install Ampps which contains all the packages in built.
The following error might be thrown for the user with new version of the system
Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated.

Installing PECL on MAMP

I have began installing pecl on MAMP. I have added the correct php version to the path and when which php it says /Applications/MAMP/... which is correct.
I have downloaded the Server Components and libraries moved them to a new folder in my php and run the ./configure everything seems to run ok and looked through all the checks being performed while installing and unpacking.
It gets to the last line and says;
configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>
Where should I set the <DIR> for the iconv?
Just make another folder and point it at that?
I am only trying to get the mongo pecl installed.
The information I have followed is here http://www.lullabot.com/blog/article/installing-php-pear-and-pecl-extensions-mamp-mac-os-x-107-lion
Wait wait wait wait. Why are you rebuilding your PHP installation to install the MongoDB driver?
You don't have to do that.
Just run e.g.:
/Applications/MAMP/bin/php/php7.1.1/bin/pecl install mongo
Assuming thats the full path to the pecl command part of your MAMP installation.
You might need to replace /php7.1.1/ with your current and active MAMP php version.
Working on this right now and found a workaround to just disable iconv with ./configure --without-iconv which not the best solution of course, but works for me.
Edit: Downloaded libiconv-1.14 package, and after running ./configure , make, make install, PHP configure runs fine.
This did it for me:
$ ./configure --with-iconv=/usr/lib/
First needed to install libxml2 and libxslt via homebrew though:
$ brew install libxml2
$ brew install libxslt

Cannot Install any PHP PECL through Cpanel (WHM) or SSH

When I try to install a module through PHP PECL through cpanel or whm (CENTOS 6.3 x86_64 / WHM 11.34.0 (build 7) ) I always get this result:
ERROR: `/root/tmp/pear/imagick/configure --with-imagick' failed The
Imagick.so object is not in
/usr/local/lib/php/extensions/no-debug-non-zts-20090626
Here in another example with html_parse:
ERROR: `/root/tmp/pear/html_parse/configure --with-ekhtml' failed The
html_parse.so object is not in
/usr/local/lib/php/extensions/no-debug-non-zts-20090626
I have googled it, done the suggestions and always the same result.
What library are you trying to install?
I've found mixed results using pecl on Redhat, centos, or fedora machinces if I've ever used yum to install their versions of PHP libs. The easiest way around your issue would be to look to see if it's in the Yum repo and install it that way:
yum search 'modulename'
yum install 'packagename'
I usually just do a yum search php and scan down the list of modules.
If you want to use pecl or can't because the libraries aren't part of yum, I'd remove the natively included version and build your PHP from scratch. You can remove PHP and related libraries installed with the distro via yum as well.
I have a similar server setup and I needed pecl_http. Instead of using WHM (Home »
Software » Module Installers) I used command line. Simply typed: pecl install pecl_http
It should be the same for other modules like the html_parse, just change the module name, like: pecl install html_parse
Figured I'd add this for anyone else looking for this info.

Categories