Reputation: 672
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:
Upvotes: 42
Views: 75468
Reputation: 1152
If what mwal wrote above doesn't work (please try their 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/[email protected]/7.3.21/pecl/20180731/redis.so (assuming you are using [email protected])
so at the top of my php.ini file is like this:
extension="/usr/local/Cellar/[email protected]/7.3.21/pecl/20180731/redis.so"
Upvotes: 13
Reputation: 620
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 :)
Upvotes: 8
Reputation: 12058
Here are steps to use pickle
, for PHP >= 7.3 (tested with 8.1):
brew install pickle
pickle install redis
php -i|grep php.ini
extension=redis
. Preferable at Dynamic Extensions
section.Bonus
If you use VS Code, to enable intellisense / auto complete, at Preference
-> paste intelephense.stubs
at Search setting box -> Add Item -> select redis
.
Upvotes: 2
Reputation: 124
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
Upvotes: 0
Reputation: 19
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
Upvotes: 0
Reputation: 3103
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.
Upvotes: 58
Reputation: 16297
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 [email protected]
make test
You can check working or not
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
Upvotes: 85