Connection to a MS SQL Server from Symfony / Doctrine on Mac or Linux

Microsoft provides a SQL Server driver for PDO. Unfortunately, this driver only works on Windows. Linux and Mac OS X apps must use the FreeTDS compatibility layer: an open source implementation of the MS SQL Server protocol for Unix.

It’s possible to connect a Symfony app to a SQL Server instance on Unix through FreeTDS but this involve to use a Doctrine driver that is not provided with the standard distribution. Some tutorials already explain how to do that, but they encourage doing dirty things like editing files in the vendor/ directory. Here is the clean way! And if you are interested in creating your own server then read more here.

The reverse engineering feature is not supported through this driver. IMO the easiest way is to generate the model from a Windows box with the official Microsoft driver (if it supports reverse engineering) then to use the model with the Linux driver.

Thanx for this great article, I learnt many interesting things.
Do you know how to get proper error messages or at least the contextual parameters for them ?
IE: Conversion failed when converting the %1 value %2 to data type %3.

Thanks for the details. I am now able to get the data from MSSQL using doctrine from app/console. But from the website code in src it says “could not find driver
500 Internal Server Error – PDOException”

Thanks for this great article. I am working on moodle having ‘Symfony 2.6.13’. By this article, I have tried to access mssql db on Mac. Working fine other than some stored procedures not called on Mac. Same stored procedures are working fine on windows. Is there any issue with these installations or I am missing some thing else?.