I’m installing the 2amigos/yii2-usuario module.
When I attempt to migrate (to the new database table structure), I get this error:
yii-adv-app> php yii migrate
PHP Core Warning ‘yii\base\ErrorException’ with message ‘PHP Startup: Unable to load dynamic library ‘zip.so’ (tried: /Applications/MAMP/bin/php/php7.4.9/lib/php/extensions/no-debug-non-zts-20190902/zip.so (dlopen(/Applications/MAMP/bin/php/php7.4.9/lib/php/extensions/no-debug-non-zts-20190902/zip.so, 0x0009): dlopen(): file not found: /Applications/MAMP/bin/php/php7.4.9/lib/php/extensions/no-debug-non-zts-20190902/zip.so), /Applications/MAMP/bin/php/php7.4.9/lib/php/extensions/no-debug-non-zts-20190902/zip.so.so (dlopen(/Applications/MAMP/bin/php/php7.4.9/lib/php/extensions/no-debug-non-zts-20190902/zip.so.so, 0x0009): dlopen(): file not found: /Applications/MAMP/bin/php/php7.4.9/lib/php/extensions/no-debug-non-zts-20190902/zip.so.so))’
yii-adv-app> php --version
PHP 7.3.11 (cli) (built: Jun 5 2020 23:50:40) ( NTS )
Copyright © 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright © 1998-2018 Zend Technologies
But php is pointing to PHP 7.3.21 system-wide… see the php --version output.
Zip.so is installed properly in 7.3.21, but I didn’t download and install for 7.4.9 (or any other unused versions of PHP).
Why is yii (from the command line) using 7.4.9, when 7.3.21 is the system version?
Is there a way to invoke yii and specify which version of PHP to use?
Your system version is 7.3.11 not 7.3.21.
Please open your Yii2 application and click on the PHP-Version on the debug toolbar. Which PHP-Version is written inside the badge?
Scroll down until you see
Loaded Configuration File . What value is there written?
EDIT: My most fault: My Webserver uses PHP74-fpm which uses the php7.4 binary but most of time I only type php instead of php7.4 before
yii command, which reults in using the system version 7.2. But you altready stated that this is not the case…?
Hello Robin, thank you for your reply.
I suppose I should have stated my platform: I’m on a Mac OSX 10.17 Catalina, running MAMP Pro 6.0.1 (Apache2.4, PHP7.3.21,MySQL 5.7)
My debugger toolbar shows PHP7.3.21 as expected since it’s running under MAMP.
The loaded configuration file is 7.3.21 from MAMP as well:
My system doesn’t have symlinks defined for php7.4 or php7.3, so I can’t use the “php7.3 yii migrate” syntax. I will try that, though.
I thought I had set the system’s /usr/bin/php as a symlink to point to MAMP’s PHP7.3.21, but obviously, that isn’t correct.
I’m still confused about how and why yii is picking up on a non-system-defined PHP version. I thought it would use PHP7.3.11, since that is the installed system version. Any reason why “yii migrate” is using PHP7.4.9 instead of 7.3.21 or 7.3.11?
Here is the top debugger bar:
Just my 2 cents: you can chose the php version on command line like so:
/usr/bin/php7.4 -f <path to php script>
Thanks, Leo, but my system doesn’t have those aliases defined. I’m using MAMP Pro, and it doesn’t automatically create aliases for the various PHP versions.
I will create those aliases manually and try it again.
I did as you suggested and defined a symlink to my PHP 7.3.21 version. Since I’m on a Mac running Catalina (which doesn’t allow sudoers to make symlinks in /usr/bin) I created the link in /usr/local/bin (which is in my $PATH anyway):
yii-adv-app/> sudo ln -s /Applications/MAMP/bin/php/php7.3.21/bin/php /usr/local/bin/php7.3.21
Then I was able to run the migrate command without the PHP warning – because I had already installed the zip.so for PHP 7.3.21 and set up the extensions in MAMP Pro’s php.ini template (see this SO post for instructions on how to change the php.ini template for MAMP Pro).
Leo and Robin,
You both suggested the same thing: add symbolic links to the php version that has the zip.so extension installed, and use that instead of the default system php.
Thank you both for your help.
Thanks Leo, but I don’t have those aliases defined on my system (MAMP Pro doesn’t automatically define aliases to the various PHP versions that come with MAMP Pro).
I will define them and try again. I’ll post whether that works or not.