Error install pecl/raphf and propro - php

I have updated php5.5 to php7.0.
I try to run this commande :
pecl install pecl/raphf
But I obtain this error :
Parse error: syntax error, unexpected 'new' (T_NEW) in /usr/share/php/PEAR/Frontend.php on line 91
How I can install :
pecl install pecl/raphf
pecl install pecl/propro

Try update PEAR:
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
Original Answer in GitHub Issue

I solving my problem :
I have unistalled php 7.0.5, and installed php 5 for get old pear version.
apt-get install php-pear
pear clear-cache
pear upgrade pear-1.10.0
Then, I am re-installed php7.0.5
It work !

Pear 1.10.0 supports php7. Upgrade your pear.
http://pear.php.net/package/PEAR/download/1.10.0

I solved my similar problem on Centos7.x for root user:
I'm remove default package:
yum remove php-pear
Next i'm install package for php7.x (for example php7.1) and default package:
yum -y install php71-php-pear && yum -y install php-pear
After install i'm find my php71-pear directory and create symlink instead of default php-pear:
find / -type d -name 'pear'
...
/opt/remi/php71/root/usr/share/doc/pear
/opt/remi/php71/root/usr/share/pear
/opt/remi/php71/root/usr/share/tests/pear
...
mv /usr/share/pear /usr/share/pear_5
ln -s /opt/remi/php71/root/usr/share/pear /usr/share/pear
Profit...
pecl -V
PEAR Version: 1.10.7
PHP Version: 7.1.5
Zend Engine Version: 3.1.0

You don't need uninstall PHP 7. You can edit /usr/bin/pear and set php=/usr/bin/php5. Then update PEAR.
I have install both php env like php5.6 and php7.1

Try update PEAR:
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar

Related

How do I install an extension of Kafka for PHP?

This is the extension that I am trying to install: https://github.com/EVODelavega/phpkafka
The messages passed to the queue should be in JSON format.
Currently, I am getting installation errors:
1. The instructions ask me to install librdkafka.
2. The installation link for the above step is this. I am unable to install using the 1st and 4th method. This is the error:
checking for librdkafka/rdkafka.h" in default path... not found
configure: error: Please reinstall the rdkafka distribution
Quick Install Steps:
Step 1 Install PHP pecl and pear commands:
sudo apt install php-pear
Step 2 Install librdkafka
sudo apt-get install -y librdkafka-dev
Step 3 Install PECL-package
sudo pecl install rdkafka
Step4 Enable PHP-extension in PHP config. Add to php.ini
sudo nano /etc/php/7.4/cli/php.ini
extension=rdkafka.so
Step 4 Restart apache server
sudo service apache2 restart
because you need another package librdkafka,you should install librdkafka first
$ git clone https://github.com/edenhill/librdkafka.git
$ cd librdkafka
$ ./configure
$ make && make install
this way can resolve your problem
For Linux Debian Stretch (9.13) actual flow is:
Install PHP pecl and pear commands:
sudo apt install php-pear
FYI: Depends on your installed PHP version you may need to use concrete version package. For example: php7.2-pear.
Add backports repository. Current ext-rdkafka depends on librdkafka version 0.11.0 or greater. So follow official instructions, but use stretch-backports.
Install librdkafka-dev package from backports:
sudo apt -t stretch-backports install librdkafka-dev
Update apt:
sudo apt update
Install PECL-package:
sudo pecl install rdkafka
Enable PHP-extension in PHP config. Add to php.ini:
extension=rdkafka.so
FYI: You need to restart php-fpm service to apply new config params.

How to install php extension using pecl for specific php version, when several php versions installed in system?

I have installed both php5.6 and php7.0 from PPA on Ubuntu according to this manual
http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu
But I didn't get how to install extensions using pecl for php5.6 or php7.0.
For example I have already installed version of libevent or amqp in php5.6.
Now when I type pecl install libevent and my active php version is php7.0 (using update-alternatives --set php /usr/bin/php7.0),peclreturns message thatlibevent` already installed.
But it was installed only for php5.6 (when this version was active) and now I want to do it for php7.0.
Which commands could help me?
UPD
I have found this commands for switch pecl to php7.0 and packet them to executable bash scripts:
#!/bin/bash
sudo update-alternatives --set php /usr/bin/php7.0
sudo pecl config-set php_ini /etc/php/7.0/cli/php.ini
sudo pecl config-set ext_dir /usr/lib/php/20151012/
sudo pecl config-set bin_dir /usr/bin/
sudo pecl config-set php_bin /usr/bin/php7.0
sudo pecl config-set php_suffix 7.0
and for php5.6
#!/bin/bash
sudo update-alternatives --set php /usr/bin/php5.6
sudo pecl config-set php_ini /etc/php/5.6/cli/php.ini
sudo pecl config-set ext_dir /usr/lib/php/20131226/
sudo pecl config-set bin_dir /usr/bin/
sudo pecl config-set php_bin /usr/bin/php5.6
sudo pecl config-set php_suffix 5.6
But they are not help, pecl still gives me list of already installed extensions to php5.6, even if I switched to php7.
pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
amqp 1.7.1 stable
libevent 0.1.0 beta
stats 1.0.3 stable
It should be empty for php7.0 !
How to solve the problem?
UPD
For amqp I have just installed php-amqp package without using pecl.
apt-get install php-amqp
And libevent still not exists for php7.
But I hadn't found a way to switch pecl installation between 5.6 and 7 version, so question is still open.
Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):
$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>
$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>
$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>
The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):
vagrant#homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages. More than one package may be
specified at once. Prefix with channel name to uninstall from a
channel not in your default channel (pecl.php.net)
Options:
...
-r, --register-only
do not remove files, only register the packages as not installed
...
The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).
When pecl throws error is already installed and is the same as the released version
Switch to required php, php-config, phpize versions before installing from pecl
Just run it installation with force flag
sudo pecl install -f <package-name>
I ran into this same issue while updating my Vagrant box with XHGui, as XHGui requires mongodb. I wanted to be able to support profiling on both PHP 5.6 and 7.0.
I dug into the pecl source code, and found that there's a metadata_dir config option. That is a path to a directory where the current state of installed packages. Unfortunately, that isn't already namespaced per PHP version. If you try and set it with pecl config-set, you get an opaque 'failed' error. It turns out that setting isn't whitelisted as being configuable in the \PEAR_Config class:
/**
* Configuration values that can be set for a channel
*
* All other configuration values can only have a global value
* #var array
* #access private
*/
var $_channelConfigInfo = array(
'php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'cfg_dir',
'test_dir', 'www_dir', 'php_bin', 'php_prefix', 'php_suffix', 'username',
'password', 'verbose', 'preferred_state', 'umask', 'preferred_mirror', 'php_ini'
);
In PECL's world, 'global' means it can only be set at install time, and not after.
There's an issue in the PPA tracker over at github: https://github.com/oerdnj/deb.sury.org/issues/407
The final suggestion there is to build the extension manually for alternate PHP versions. I ended up using pecl for PHP 7 extensions, and manual builds for 5.6. Make sure you run update-alternatives for php-config and phpize, and not just php before building:
update-alternatives --set php /usr/bin/php5.6
update-alternatives --set php-config /usr/bin/php-config5.6
update-alternatives --set phpize /usr/bin/phpize5.6
Then, extract the extension and build it. These steps from the above issue worked for me with the mongodb extension:
phpize5.6 && ./configure --with-php-config=php-config5.6 && make && sudo make install
First of all, get admin permission in Linux Environment-
**Sudo su **
<>
Then follow below syntax
sudo apt-get install php7.3-bcmath
Here php7.3 (Enter your php version and check by php -v)
bcmath (Enter your extension name)
And if you want to check list of active extensions enter (php -m) in terminal.

laravel composer update : the requested PHP extension dom is missing from your system

I am using ubuntu 16.04, laravel 5.2
when i run update composer in my project directory its showing
"the requested PHP extension dom is missing from your system"
i checked installed packages of PHP, its available there
Installing xml-extension (php7.0-xml in my case) solved the problem
sudo apt-get install php-xml
If PHP version is 7.2, execute the following command
sudo apt-get install php7.2-xml
Managed to fix it with a php version 5.6* :
$ sudo apt-get update
$ sudo apt-get install php5.6-xml
You might have some missing dependencies, so first run
sudo apt-get -f install
Then install php-xml
sudo apt-get install php-xml
This worked for me.
DOM is a PHP extension and not a PHP package. This means that your version of PHP needs to be recompiled with the extension. It is possible however that your PHP was already compiled with DOM but that DOM is not enabled.
You can check this in your php.ini (search for extension=dom.so and make sure it's uncommented).
In my case I use
sudo apt-get update
and
sudo apt-get install php7.3-xml

RuntimeException The Zip PHP extension is not installed

I'm a newbie in Linux I just installed composer and laravel...
but when i run the laravel new project i get the following error:
[RuntimeException]
The Zip PHP extension is not installed. Please install it and try again.
I don't know how to install that extension...
please help
Try type into the command line:
sudo apt-get install php7.0-zip
Verify from any route with:
dd(get_loaded_extensions());
This worked for me, good luck.
for php 7.0
sudo apt-get install php7.0-zip
for php 7.1
sudo apt-get install php7.1-zip
and so on!
I got the same issue and tried to install the extension with the command sudo apt install php7.0-zip but still got the same error. I finally solved it with sudo apt install php-zip
I was using php7.0-zts.The solution was to uninstall all the ZTS packages and revert to the regular php7.0 packages.
use this sudo apt-get install php-zip
The php version will be sorted out by the system.
This is outdate using brew doctor and brew cleanup. Brew doctor will give you some fixes that will help you install laravel.
composer global require laravel/installer\n && brew install php
installing on CentOS
try yum search zip |grep -i php and install with package name came back
like - sudo yum install ea-php73-php-zip.x86_64
You can use php-zip or php-zip7.x package from apt. Such as:
sudo apt-get install php-zip
Many packages in apt have a default version such as php-zip then explicit version(s). In order to search apt for packages you can always use
apt-cache search keyword
Or in this example specifically either
apt-cache search zip
apt-cache search php-zip
Which will allow you to find the php-zip and php-zip7.4 (at the time of writing this comment) package to install.
Very useful command to when you're trying to satisfy some dependency and cannot find the package name.

Installing/enabling PHP Pecl Intl extension on a default Mac OS X Leopard bundled PHP configuration

How can I install or enable the PHP Pecl Intl extension in my PHP environment?
I've got a stock PHP configuration that came bundled with Mac OS X Snow Leopard.
Installing libicu from source and than $pecl install intl results in the following error:
/private/tmp/pear/temp/intl/collator/collator_class.c:92: error: duplicate 'static'
/private/tmp/pear/temp/intl/collator/collator_class.c:96: error: duplicate 'static'
/private/tmp/pear/temp/intl/collator/collator_class.c:101: error: duplicate 'static'
/private/tmp/pear/temp/intl/collator/collator_class.c:107: error: duplicate 'static'
make: *** [collator/collator_class.lo] Error 1
ERROR: `make' failed
Any help is really appreciated!
Here's what I did in OSX 10.9 Mavericks:
Install some dependencies with Homebrew:
$ brew install autoconf
$ brew install icu4s
$ brew link --force icu4s
Install and verify Pear/PECL (instructions from http://techtastico.com/post/como-instalar-pear-y-pecl-en-os-x-mavericks/):
$ curl -O http://pear.php.net/go-pear.phar
$ sudo php -d detect_unicode=0 go-pear.phar
[ Select 1 and enter /usr/local/pear ]
[ Select 4 and enter /usr/local/bin ]
[ Press return ]
$ pear version
Install PECL intl:
$ sudo pecl install intl
$ sudo cp /private/etc/php.ini{.default,}
$ sudo chmod 644 /private/etc/php.ini
$ echo extension=intl.so >> /private/etc/php.ini
For the time being I've recompiled my PHP installation. I've created a gist with my configure string which I'll keep updating.
update
liip have created a nice binary that circumvents all these troubles. It is based on the original entropy.ch binary, I recomend using it for PHP development on a Mac.
Better late than never, but if you are like me and installed PHP directly from php.net (instead of using something like Homebrew or Port, then you can simply follow the following link to install Pear and PECL:
http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/
It worked fine for me.
on my Mac I installed a php version with pear using brew. This solved all my issues as the default osX php didn't work for me after trying many different ways. You can try without installing php/pear if you have already done so.
You need Homebrew http://brew.sh/
Install PHP
brew install php56 --with-pear or brew install php56 pear
Install autoconf
brew install autoconf
Install icu4c
brew install icu4c
Creates the symlinks
brew link --force icu4c
Install intl with (pearl) pecl
sudo pecl install intl
Homebrew should enable intl and symlink all the right versions to their respective commands.

Categories