Issue: Sodium Extension Error in Magento 2.4.5/2.4.6 After Installing XAMPP (PHP v8.1.x) on Windows
After installing XAMPP (PHP v8.1.x) on Windows, you may encounter an issue related to the sodium extension when running Magento 2.4.5 or Magento 2.4.6. The error message might look like this:
main.CRITICAL: Error: Undefined constant "Magento\Framework\Encryption\Adapter\SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES"
This error occurs because the sodium extension is not loaded.
How to Fix This Issue:
-
Enable the Sodium Extension:
-
Open your
php.inifile. -
Search for
extension=sodium. -
Uncomment this line by removing the semicolon (
;) at the beginning of the line.
-
-
Copy the
libsodium.dllFile:-
Copy the
libsodium.dllfile fromxampp/php/and paste it into thexampp/apache/bin/directory.
-
-
Restart Apache:
-
Restart Apache to apply the changes.
-
Verify the Fix:
To verify that the issue has been resolved, run phpinfo() in your browser. Look for the table showing the Sodium extension support. It should look similar to the screenshot below:
