Getting Symfony 1.4 to Run on a Windows Server Running PHP >= 5.3

If you’re running a LAMP environment, you might wonder what’s the big deal, it should just work right? No. When PHP upgraded from the 5.2 series to the 5.3 series, it dropped its support for the MSSQL driver (php_mssql.dll) and was not going to continue support. You had to use Microsofts SQLSRV driver (http://www.php.net/manual/en/intro.mssql.php) Well that’s ok, you could use the PDO_DBLIB… nope, PHP quit supporting that on all Windows servers running PHP >= 5.3. (http://php.net/manual/en/ref.pdo-dblib.php) *fudge*

Ok, so now we have the SQLSRV driver from Microsoft, sweet. No… wait… Symfony 1.4 uses a Doctrine version that has no idea what SQLSRV is! *sigh* Hmm, maybe we can use the PDO_SQLSRV that Microsoft developed? Well, that should work (and actually does) except the older Doctrine version is not aware of pdo_sqlsrv’s existence. So lets make it aware!

Making Symfony 1.4 PDO_SQLSRV aware

Before you being, please make sure you have the following installed:

REQUIRED
PDO SQL Drivers: http://www.microsoft.com/en-us/download/details.aspx?id=20098

SQL Server 2012 Client: http://www.microsoft.com/en-us/download/confirmation.aspx?id=29065

First we need to create the PDO_Sqlsrv class. I’ll I did was copy the existing Doctrine_Connection_Mssql class and renamed it to Doctrine_Connection_Sqlsrv. You can do this because there is nothing special about the SQL code, it’s all just handled by the DLL. Doctrine just needs a class to run.

Once you’ve done that, you need to tell Doctrine_Manager about your new connection driver. Go to line 82 and add your new class to the $_connectionDrivers array:


protected $_connectionDrivers = array(
'db2' => 'Doctrine_Connection_Db2',
'mysql' => 'Doctrine_Connection_Mysql',
'mysqli' => 'Doctrine_Connection_Mysql',
'sqlite' => 'Doctrine_Connection_Sqlite',
'pgsql' => 'Doctrine_Connection_Pgsql',
'oci' => 'Doctrine_Connection_Oracle',
'oci8' => 'Doctrine_Connection_Oracle',
'oracle' => 'Doctrine_Connection_Oracle',
'mssql' => 'Doctrine_Connection_Mssql',
'dblib' => 'Doctrine_Connection_Mssql',
'odbc' => 'Doctrine_Connection_Mssql',
'sqlsrv' => 'Doctrine_Connection_Sqlsrv',
'mock' => 'Doctrine_Connection_Mock'
);

Finally, tell Doctrine to use Sqlsrv (config_databases.yaml)


return array(
'doctrine' => new sfDoctrineDatabase(array (
'dsn' => 'sqlsrv:server=my.db.server;Database=my_db',
'username' => $username,
'password' => $password,
'name' => 'doctrine',
)),);

Wala, Symfony 1.4 should now be running on your Windows Server running PHP 5.3 and 5.4.