Hi
I'm looking at using Valet+ for Magento2 local development - we're currently using docker
On installation, things started throwing errors, in particular
PHP Warning: Module 'apcu' already loaded in Unknown on line 0
and
PHP Parse error: syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2
Searching through the issues did not yield a fix, and so, looking at my system, in this file:
/usr/local/etc/valet-php/7.1/php.ini
I see this in the beginning of that file
extension_dir = "/usr/local/lib/php/pecl/20160303"
zend_extension="xdebug.so"
extension="apcu.so"
extension="geoip.so"
extension="apcu.so"
extension="apcu.so"
extension="apc.so"
extension="apc.so"
My question is, why is that duplication there, and what is the "valet way" for removing that?
UPDATE:
Manually removing those duplicate entries (the order seems tom change between 7.1 and 7.2) gets rid of the errors
UPDATE:
After enabling xdebug I see the duplication is back - could be the culprit?
valet xdebug on --remote_autostart=1
/usr/local/etc/valet-php/7.1/php.ini
zend_extension="xdebug.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"
zend_extension="xdebug.so"
extension="apcu.so"
extension="apcu.so"
extension="geoip.so"
I saw this today on my colleague laptop
I had to set
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
Closing this ticket because it can be fixed
I am running into the same issue, have added the export flags to my ~/.bash_profile file, but after running 'valet install' the issue returns and the double extensions are set.
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
I experienced the same issue after uninstalling and installing Valet+. Error message:
PHP Warning: Module 'apcu' already loaded in Unknown on line 0
PHP Warning: Module 'apcu' already loaded in Unknown on line 0
PHP Parse error: syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2
PHP Warning: Module 'apcu' already loaded in Unknown on line 0
PHP Warning: Module 'apcu' already loaded in Unknown on line 0
PHP Parse error: syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2
PHP Warning: Module 'apcu' already loaded in Unknown on line 0
Warning: Module 'apcu' already loaded in Unknown on line 0
Could not open input file:
Warning: Module 'apcu' already loaded in Unknown on line 0
Parse error: syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2/cli/valet.php
Tried adding this to my shell profile, but it didn't affect the error:
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
php.iniI'm guessing the duplicates are leftover from the previous Valet+ install, and the install doesn't de-duplicate them. When I checked the php.ini file for each PHP version that Valet installed this is what I found initially:
Initially there was a duplicate entry for apcu.so:
extension="apcu.so"
extension="apc.so"
extension="apcu.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"
Which I changed to:
extension="apcu.so"
extension="apc.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"
Then ran valet install which succeeded:

But failed to setup the MySQL root password properly, so I ran:
brew link --force [email protected]
valet install
Which then fully worked.
And afterward that php.ini file had been rewritten with:
extension="apcu.so"
extension="geoip.so"
extension="yaml.so"
extension="apc.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"
The 7.2 php.ini didn't have any extensions listed before/after trying to fix and running valet install. After switching I had to make similar changes to its php.ini file.
I ran into the same issue with 7.1. I followed the fix provided by @brendanfalkowski to remove the duplicate apcu.so extension, and the installation succeeded.
Could we reopen this? It seems to occur on a fresh install (removing the php.ini files and reinstalling everything).
Issue on duplicate apcu.so and apc.so will occur again when changing php version. I need to remove duplicates every time I change php version. Ticket should be reopen.
This is also occurring on a colleague's laptop on a fresh install.
The install command duplicates the apcu.so extension and then later results in a failure that prevents the install process from completing, making this package completely unusable.
Ended up going with a standard Laravel Valet install and enabled XDebug myself.
Brand new imac, fresh Mojave 10.14.6 install, same issue.
Moving back to Laravel Valet for now.
I am having same issue - brand new iMac, Mojave 10.14.16 install as well. Keep running into issues including this one. Trying to run php7.2 to install magento 2.3.3
Does this have a resolution?
R.I.P valet-plus
3 days trying to make this work
Moving back to Laravel Valet for now too.
What worked for me was removing all the lines at the top of:
usr/local/etc/valet-php/7.1/php.ini
I went from:
extension="apcu.so"
extension="apc.so"
extension="apcu.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
and changed that to only have
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
I then run
valet fix
valet install
Which made it install without a problem for me.
Well done. Clever boy.
@squishz that works, but it's only a temporary work-around. There's definitely a bug somewhere that causes these duplications to happen. I keep getting them back.
Most helpful comment
I experienced the same issue after uninstalling and installing Valet+. Error message:
Failed — adding flags to my shell profile
Tried adding this to my shell profile, but it didn't affect the error:
Succeeded — editing
php.iniI'm guessing the duplicates are leftover from the previous Valet+ install, and the install doesn't de-duplicate them. When I checked the
php.inifile for each PHP version that Valet installed this is what I found initially:File: /usr/local/etc/valet-php/7.1/php.ini
Initially there was a duplicate entry for
apcu.so:Which I changed to:
Then ran
valet installwhich succeeded:But failed to setup the MySQL root password properly, so I ran:
Which then fully worked.
And afterward that
php.inifile had been rewritten with:File: /usr/local/etc/valet-php/7.2/php.ini
The 7.2
php.inididn't have any extensions listed before/after trying to fix and runningvalet install. After switching I had to make similar changes to itsphp.inifile.