How to fix command not found brew on mac with zsh

I got a new MacBook Pro with M2 chip last week. As a web programmer, I needed to install php on macOS. Followed by the php.net provided install instruction, I installed php on macOS with homebrew. After installing homebrew, I used the command “brew install php”, but got an error message: “zsh: command not found: brew”. Here is the solution that I fix this problem.