This is a weird thing only occurs on Mac where Sphinx not running. Until I narrow down the possible issue and find out particularly the searchd isn’t running as daemon in the background. That’s why I keep getting connection refused error message as below in the terminal.
Query failed: connection to localhost:9312 failed (errno=61, msg=Connection refused).
It can be tested by running php in the terminal rather than just browser, because browser won’t give you a hint what is going wrong.
After that I finally found a temporary solution for this! Just force it run as console mode in terminal. Then that will do.