I have installed libsodium and libsodium-php on ubuntu 16.04 but when I run:
`<?php
var_dump([
\Sodium\library_version_major(),
\Sodium\library_version_minor(),
\Sodium\version_string()
]);`
I get an error saying:
PHP Fatal error: Uncaught Error: Call to undefined function Sodium\library_version_major()
According to phpinfo() Sodium is enabled and the compiled version is 2.0.1 and the library version is 1.0.13. What am I doing wrong?
The PHP API for libsodium has changed in version 2.0.0 of the extension.
Originally, all functions were in a \Sodium\
namespace.
However, following a vote by PHP developers regarding its inclusion in PHP 7.2, it was decided to move everything to the global namespace instead.
So, what used to be \Sodium\library_version_major()
is now sodium_library_version_major()
.