Sodium is not loading on XAMPP PHP 7.2

Amplifier picture Amplifier · Jan 16, 2018 · Viewed 11.9k times · Source

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.

Answer

Thomas Wickert picture Thomas Wickert · May 1, 2018

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