Overview
Passwords should never be stored as plaintext or protected with fast general-purpose hashes such as plain MD5 or SHA-1. Password storage requires a password-hashing algorithm designed to make offline guessing more expensive.
PHP built-in functions
PHP provides password_hash() to create password hashes and password_verify() to check a submitted password. Store the complete resulting hash string because it contains the algorithm and parameters needed for verification.
Operational practices
Use an appropriate algorithm and cost for the deployed PHP version and server capacity. Reassess parameters as hardware changes, use HTTPS for login flows, rate-limit authentication attempts and avoid logging passwords or authentication secrets.
Migration
When changing hashing parameters, PHP's password_needs_rehash() can help identify hashes that should be upgraded after a successful login.