Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sodium is not loading on XAMPP PHP 7.2

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.

like image 549
Amplifier Avatar asked Jan 16 '18 17:01

Amplifier


People also ask

How do I enable sodium PHP extension?

In order to use this extension you must compile PHP with sodium support by using the --with-sodium[=DIR] configure option.

What is PHP extension sodium?

The php-sodium extension provides strong encryption capabilities in an easy and consistent way. Note that, for sites not having the extension installed, a php-openssl based solution, considered suboptimal, is used, and this fallback will stop working in a few versions (Moodle 4.2).


1 Answers

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
like image 57
Thomas Wickert Avatar answered Oct 21 '22 14:10

Thomas Wickert