php hash_file equivalent to javascript

has anyone encountered the issue where the value generated using the hash_file function in PHP with “sha256” does not match the one from CryptoJS.createHash(“sha256”, …)?
This is my php code:
hash_file("sha256", $filePath)

this is javascript code:
const hash = crypto.SHA256(crypto.lib.WordArray.create(buffer)); const hexHash = hash.toString(crypto.enc.Hex);

How can this be handled so that both values are the same?