问题
Hey for some reason when i use XAMPP PHP 7.2, all of the sodium functions are not working. When i run print_r(get_loaded_extensions());
it does not show sodium on the list. When i go to http://php.net/manual/en/sodium.installation.php it says no installation needed they are a part of the core. So i went to my php.ini
configuration file and made sure that it did not disable sodium, it says extension=php_sodium.dll
. I went to the console to double check to see if their were any errors, there was none. It was weird because Argon2i
is working fine. The Argon2i constants are all defined and when used in the password_hash()
function it generates a password hash no problem. I am using windows as my OS. Is there anything else that can cause something like this, any help would be nice. Thanks in advance.
回答1:
Are you sure that you edit the correct php.ini?
Starting with PHP 7.2, ini file (at least on my Windows PC), the syntax to load extension is now extension=modulename
instead of extension=php_modulename.dll
.
回答2:
For Windows XAMPP PHP 7.2.4, to correct the Error:
PHP Warning: PHP Startup: Unable to load dynamic library 'sodium' (tried: C:\xampp\php\ext\sodium (The specified module could not be found.), C:\xampp\php\ext\php_sodium.dll (The specified module could not be found.)) in Unknown on line 0
There must be a copy of php/libsodium.dll (PHP Extension) in apache/bin/ (Apache Module). It is assumed, but not tested, that it must be same file.
Assuming that php/libsodium.dll and php/ext/php_sodium.dll are the same build, which is the case with a new install of XAMPP 7.2.4, the install is:
1. Add "extension=sodium" to php.ini (no quotes)
2. Copy php/libsodium.dll to apache/bin/
3. Restart Server
回答3:
I encountered the same problem, but reinstall XAMPP 7.2 doesn't help.
Finally, I returned to XAMPP 7.1.14 then installed sodium additionally, and it works.
- Install XAMPP(xampp-win32-7.1.14-0-VC14)
- Download libsodium named php_libsodium-2.0.9-7.1-ts-vc14-x86.zip
- Rename php_sodium.dll to php_libsodium.dll, then put it into C:\xampp\php\ext
- Put libsodium.dll into C:\xampp\apache\bin
- Add into php.ini:
extension=php_libsodium.dll
I know rollback is not a good idea.
But at least it works for me.
回答4:
Open php.ini file from C:\xampp\php\ -> under Dynamic Extensions and add
extension=sodium
回答5:
For anyone struggling with this in Windows XAMPP including PHP 7.3.9:
There is already a libsodium.dll file in c:\xampp\xampp\php.
However, the extension is not activated by default in the php.ini file. Simply edit the file as @Alshoja indicated. In fact, the needed entry is already there but commented out, simply remove the comment:
#extension=sodium;
to
extension=sodium;
Restart the server, then verify through phpinfo(); and searching for "sodium" you should now see a "sodium support" column with associated information.
来源:https://stackoverflow.com/questions/48287186/sodium-is-not-loading-on-xampp-php-7-2