Are there best practices for generating and storing new passwords in PHP applications, especially when using MD5 encryption?

When generating and storing new passwords in PHP applications, especially when using MD5 encryption, it is important to follow best practices to ensure security. One recommended approach is to use a combination of secure password hashing algorithms like bcrypt or Argon2 instead of MD5, as MD5 is considered to be a weak hashing algorithm. Additionally, it is crucial to use a unique salt for each password to add an extra layer of security.

// Generate a unique salt for each password
$salt = uniqid(mt_rand(), true);

// Generate a secure hash using bcrypt algorithm
$password = 'password123';
$hashed_password = password_hash($password . $salt, PASSWORD_BCRYPT);

// Store the hashed password and salt in the database
// Make sure to store the salt along with the hashed password for verification