'PHP: Argon2 hashing dumps without being catchable

I want to switch from bcrypt to Argon2 encryption. phpinfo() returns ARGON2 being available:

 SNIP
 '--with-iconv-dir=/Applications/MAMP/Library'
 '--with-sodium=/Applications/MAMP/Library'
 **'--with-password-argon2=/Applications/MAMP/Library'**
 '--disable-cgi' '--with-zip' '--with-xmlrpc' 
 SNAP

PHP Version 7.4.9

According to the documentation I have written the following lines of code:

$options = [  
    'memory_cost' => PASSWORD_ARGON2_DEFAULT_MEMORY_COST,  
    'time_cost' => PASSWORD_ARGON2_DEFAULT_TIME_COST,  
    'threads' => PASSWORD_ARGON2_DEFAULT_THREADS,  
];
// encrypt the user's password with the ARGON2 algorithm
try {
     $userPasswordHash = password_hash($password, PASSWORD_ARGON2ID, $options);
} catch (Exception $exp) {
     $error = $exp->getMessage();
}

I also tried with parameter "PASSWORD_ARGON2I"....

This dumps without the catch block being called. How am I able to find out what's the issue?

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source