Installing composer with Xampp on Ubuntu [duplicate] - php

I am trying to install Composer on my KnownHost VPS. When I run this command:
curl -sS https://getcomposer.org/installer | php
I get this error message:
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 phar extension is missing.
Install it or recompile php without --disable-phar
How do I install the phar extension? I am running PHP 5.4.22 on my VPS.

You can modify your php.ini file to get this working. (Some hosts use a phprc file to enable different settings in PHP instead of php.ini. #jerrygarciuh On dreamhost, follow the directions here)
After you have added your php.ini/phprc file, add these lines to the file (just the first line if your server doesn't use Suhosin for security):
extension = phar.so
suhosin.executor.include.whitelist = phar
restart php if you need to (insert php version number with no decimals if different):
killall -9 php70.cgi
then check to make sure it is working:
php -m | grep Phar
Finish with the install of composer and you should be good to go.

Mind to install phar extension for php.
urpmi php-phar
or
apt-get install php-phar

In the end I solved this by getting my host to rebuild PHP with PDO support.

I got the same issue in Ubuntu 16.04. After wasting two hours, I came up with this solution:
First install your required PHP version: sudo apt install php7.2
Install the composer. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Check whether the composer is working by simply typing
composer
If the composer is working properly, you are good to go.

Related

Composer install return problems for missing extensions [duplicate]

I am trying to install Composer on my KnownHost VPS. When I run this command:
curl -sS https://getcomposer.org/installer | php
I get this error message:
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 phar extension is missing.
Install it or recompile php without --disable-phar
How do I install the phar extension? I am running PHP 5.4.22 on my VPS.
You can modify your php.ini file to get this working. (Some hosts use a phprc file to enable different settings in PHP instead of php.ini. #jerrygarciuh On dreamhost, follow the directions here)
After you have added your php.ini/phprc file, add these lines to the file (just the first line if your server doesn't use Suhosin for security):
extension = phar.so
suhosin.executor.include.whitelist = phar
restart php if you need to (insert php version number with no decimals if different):
killall -9 php70.cgi
then check to make sure it is working:
php -m | grep Phar
Finish with the install of composer and you should be good to go.
Mind to install phar extension for php.
urpmi php-phar
or
apt-get install php-phar
In the end I solved this by getting my host to rebuild PHP with PDO support.
I got the same issue in Ubuntu 16.04. After wasting two hours, I came up with this solution:
First install your required PHP version: sudo apt install php7.2
Install the composer. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Check whether the composer is working by simply typing
composer
If the composer is working properly, you are good to go.

Install phpredis MAC OSX

Can anyone help me install php-redis in MAC OSX .
brew install php-redis
not working.
pecl install php-redis
also not working getting -
invalid package name/package file "php-redis".
Homebrew Error:
homebrew_error
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
Add extension=redis.so in your php.ini
brew services restart php#7.2
make test
You can check working or not
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
As of 2019, with homebrew php7.2 and up, pecl is now installed by default alongside the php binaries.
To see this for yourself type which pecl.
Steps to install
Check your version of redis, then find a suitable version of the extension here.
If unfamiliar with pecl, type pecl to see the options.
Issue pecl install redis-5.0.2. (or your version). Enter no to each question asked if you're not sure.
If that succeeds check the new file it created at: /usr/local/lib/php/pecl/20180731/redis.so
The install will have added extension="redis.so" to top of your php ini.
Check that by opening the file /usr/local/etc/php/7.3/php.ini.
(assuming you're on 7.3 there)
brew services restart php.
php -i | grep Redis
Redis Support => enabled
Redis Version => 5.0.2
This is what I just did in September 2019 and it works for me.
If what mwal wrote above doesn't work (please try his/her answer first),
first, try to uninstall first (if you have it but broken):
sudo pecl uninstall redis
and after that run:
sudo pecl install redis
After that, ini the php.ini, use full path for the extension.
Mine was /usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so (assuming you are using php#7.3)
so at the top of my php.ini file is like this:
extension="/usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so"
Here are steps to use pickle, for PHP >= 7.3 (tested with 8.1):
brew install pickle
pickle install redis
Find your php.ini location via php -i|grep php.ini
Edit the php.ini, insert extension=redis. Preferable at Dynamic Extensions section.
No restart of Apache httpd service is required. You may test your PHP code with Redis
Bonus
If you use VS Code, to enable intellisense / auto complete, at Preference -> paste intelephense.stubs at Search setting box -> Add Item -> select redis.
If you got the following error,
Please make sure the PHP Redis extension is installed and enabled
despite doing everything in the verified answer above, try valet restart . It worked for me
I have tried all these solutions but didn't work for me for a while so I tried this link https://developer.redis.com/develop/php/ from the original docs and it works as charm
If someone gets an error during sudo pecl install redis
Warning: mkdir(): File exists in System.php on line 294
PHP Warning: mkdir(): File exists in /opt/homebrew/Cellar/-----/pear/System.php on line 294
that means you need to create the broken directory manually.
Try to create the directory...
pecl config-get ext_dir | pbcopy
mkdir -p {paste clipboard value}
# in my case, it was
mkdir -p /opt/homebrew/lib/php/pecl/20200930
Now try to install any pecl extensions.
sudo pecl install redis
After installing any extension, restart php
brew services restart php
Happy coding :)

installing composer on centos

I'm trying to install composer on my server (centos) but I keep getting this error :
The phar extension is missing.
Install it or recompile php without --disable-phar
ps:I am trying to install composer to work with laravel
Specifically for CentOS
Edit the file /etc/php.d/20-phar.ini and remove the ; character in front of the line:
extension=phar.so
Now the phar extension is enabled.
Composer is provided as a phar as that extension is a standard part of PHP 5.3 which is also the minimum required version for running Composer at all.
If you have a weird version of PHP 5.3+ without the phar extension you could also convert it to a zipball or tarball via online tools, unpack it to /usr/local/share/composer, and then symlink manually from /usr/local/bin/composer to /usr/local/share/composer/bin/composer. Assuming no other settings are preventing installation that should work as well.
PHAR is part of the PHP core since some years now. Its already installed as dynamic/shared extension, but probably and simply not activated in your case
Please check your php extension folder for a file "phar.so".
To enable the extension:
Go to your php.ini and enable extension = phar.so
Check the loaded PHP Extensions with php -m and look for "Phar"
Then re-run the Composer install
First, you need to get composer.phar by doing :
curl -sS https://getcomposer.org/installer | php
And move the composer.phar for using globally :
mv composer.phar /usr/local/bin/composer

How do I install / enable the PHP phar extension?

I am trying to install Composer on my KnownHost VPS. When I run this command:
curl -sS https://getcomposer.org/installer | php
I get this error message:
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 phar extension is missing.
Install it or recompile php without --disable-phar
How do I install the phar extension? I am running PHP 5.4.22 on my VPS.
You can modify your php.ini file to get this working. (Some hosts use a phprc file to enable different settings in PHP instead of php.ini. #jerrygarciuh On dreamhost, follow the directions here)
After you have added your php.ini/phprc file, add these lines to the file (just the first line if your server doesn't use Suhosin for security):
extension = phar.so
suhosin.executor.include.whitelist = phar
restart php if you need to (insert php version number with no decimals if different):
killall -9 php70.cgi
then check to make sure it is working:
php -m | grep Phar
Finish with the install of composer and you should be good to go.
Mind to install phar extension for php.
urpmi php-phar
or
apt-get install php-phar
In the end I solved this by getting my host to rebuild PHP with PDO support.
I got the same issue in Ubuntu 16.04. After wasting two hours, I came up with this solution:
First install your required PHP version: sudo apt install php7.2
Install the composer. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Check whether the composer is working by simply typing
composer
If the composer is working properly, you are good to go.

PHP redis error

I installed the php redis extension. But when I run the test code, I got the following error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/redio.so' - /usr/lib/php5/20090626+lfs/redio.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Class 'Redis' not found in /var/www/test/redisTest.php on line 2
My php version is 5.3.10, I installed the new version of phpredis.
May I get your help?
THANKS!
The install steps are:
git clone https://github.com/nicolasff/phpredis.git
cd phpredis
phpize
make
make install
Then add a config file in /etc/php5/fpm/confi.d to load redis.so
I use PHP 5.3 and installing PHP-Redis using below steps worked just fine for me:
Install pecl extensionsudo pecl install redis
In php.ini, you may need set extension_dir to correct value. (can be usr/lib64/php/modules as above command placed the redis.so in this directory). In my case, I didn't set this.
Add below line to php.ini:extension=redis.so
Restart Apache/PHP-FPM
To verify if you have got redis installed you can do this
php -m | grep redis
Create a file PHP with echo phpinfo(); in it and see if the module is showing up. If you do not see the module then it is not being loaded correctly.
In the PHP5.3 and Amazon Linux AMI (Same as Centos OS 5)
install libs
yum install php-pear php-devel make gcc wget
install redis
cd /opt/
mkdir /opt/redis
wget https://redis.googlecode.com/files/redis-2.6.14.tar.gz "or last version"
tar -zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make
make install
install php-redis by pecl
pecl install redis
configuration option "php_ini" is not set to php.ini location
You should add "extension=redis.so" to php.ini
reload the web service httpd
service httpd reload
verify that the extension has been installed
php -m
[PHP Modules]
bz2
...
**redis**
...
[Zend Modules]
Download the proper library file according to your server environment( ex. x86). also, check for your PHP is thread-safe or not and download the Redis library accordingly. then place the library file inside the extension folder. you need to mention the library inside your php.ini as given below.
extension=redis.dll
then restart the server once, and check it's working properly or not.
if you have command line PHP, you can check it in the command line PHP as,
php r("print_r(get_loaded_extensions());")

Categories