目前在虚拟环境中将PHP与SQL SERVER 2012连接起来

SUMMARY
I have installed sqlsrv from the terminal in my macos Mojave, and it seems to work. I can connect my database from SQL server 2012 to my mac in the terminal using

sqlcmd -S 127.0.0.1 -U sa -P your_password

but when I want to access the database from the PHP. it says Connection could not be established.

Array ( 
  [0] => Array ( 
    [0] => 01000 [SQLSTATE] => 01000 
    [1] => 0 
    [code] => 0 
    [2] => [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libmsodbcsql.17.dylib' : file not found
  )
)

So I check the file using the terminal and it's actually is there physically. But I don't understand why it still hasn't work.

What I've tried

I tried deleting and copying the files back, but that doesn't work I tried doing anything that is suggested from lots of webs yet it still hasn't worked for all the files they asked me to copy is already exists.

The Code I Use

$serverName = "ip_address";

$connectionInfo = array("UID" => "username", "PWD" => "password", 
"Database"=>"databasename");

$connection = sqlsrv_connect($serverName, $connectionInfo);

if( $connection )
{
     echo "Connection established.
";
}
else
{
     echo "Connection could not be established.
";
     die( print_r( sqlsrv_errors(), true));
}

What I'm hoping for is that my web can access the database.