weprovide / valet-plus

Blazing fast macOS PHP development environment
1.56k stars 211 forks source link

Installing redis@8.1 against valet-plus 3.0.0 completely breaks valet #631

Closed redhatnick closed 6 months ago

redhatnick commented 7 months ago

Working on restoring my workflow on valet-plus 3.0.0, however after installing shivammathur/extensions/redis@8.1 with valet-plus now completely breaks any further valet command with the error message:

PHP Fatal error: Cannot declare class Redis, because the name is already in use in /Volumes/Starship_HD/nicholas/.composer/vendor/weprovide/valet-plus/cli/includes/facades.php on line 0

Hint: may be related to https://github.com/weprovide/valet-plus/issues/42. I noticed the fixes implemented https://github.com/weprovide/valet-plus/commit/e5d71bd719258363e9f87f83b06329e319d40b48 are also no longer present as of 3.0.0, but this stuff is also way above my pay grade so I'm not qualified to determine if this is an issue or not but thought I would ask!

mischabraam commented 7 months ago

Thanks. Totally unaware of that namespace issue. I wondered why that class in Valet+ was called RedisTool, now I know. I'll fix it.

Question though. How did you install Redis? Did you use valet-plus redis on? Doing this doesn't install shivammathur/extensions/redis@8.1. Is this required?

mischabraam commented 7 months ago

Fixed in https://github.com/weprovide/valet-plus/releases/tag/3.0.1

redhatnick commented 7 months ago

Thank you @mischabraam. I can confirm my workflow is restored effective 3.0.1.

How did you install Redis? Did you use valet-plus redis on?

Yes

Doing this doesn't install shivammathur/extensions/redis@8.1. Is this required?

valet-plus redis on only installs the redis server and allows me to manage it through valet.

shivammathur/extensions/redis@8.1 and it's dependency shivammathur/extensions/igbinary@8.1 are required if you want to use redis from your php-based application https://github.com/phpredis/phpredis.

While Valet supports multiple PHP versions, I wasn't sure if valet was also in the business of also installing php extensions as well.

When running valet-plus redis on, it might be an improvement to maybe 1) install it for the user, 2) ask the user if they want it installed, or 3) leave a message on the console to remind the user to run brew install shivammathur/extensions/igbinary@x.x shivammathur/extensions/redis@x.x (substitute X for the appropriate php version your running) to enable php-redis support.

mischabraam commented 7 months ago

Great and thanks for confirming.

Valet+ installs a couple of php extensions by default, also when you switch php versions. These default php extensions are apcu, ds, yaml and imagick. Valet+ also supports installing some php extensions with an on/off mode, like xdebug and some memcache php extensions.

So, yeah it's possible to install php extensions for redis when you do redis on. And also remove them when you do redis off. Currently you'll have to do redis on and manually install the php extensions. Valet+ breaks when you do redis off because of the remaining php extensions. This would be solved when Valet+ manages the required php extensions for Redis for you.

mischabraam commented 6 months ago

I added support of installing and removing shivammathur/extensions/redis@8.1 and it's dependency shivammathur/extensions/igbinary@8.1 when you do either valet-plus redis on or valet-plus redis off.