I need to connect a SQL Server 2008 database to Laravel 4. I've been researching and haven't found a solution for the scenario in which I find myself.
I'm using Laravel using the XAMPP package (PHP 5.5.6 –with-mssql) on MAC OS X 10.9 with FreeTDS working perfectly when I use the mssql_* php functions in other applications where I don't use Laravel.
When I do a simple SQL DB query I get the following error:
PDOException: could not find driver
My configuration in /app/database.php looks like this:
'default' => 'sqlsrv', 'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => 'ip do servidor', 'database' => 'nome da base', 'username' => 'sa', 'password' => 'senha', 'prefix' => '', ),
In php.ini, I uncommented the line:
However, checking the PHP documentation I found the information: "The PDO_SQLSRV extension is only compatible with PHP running on Windows. For Linux, see ODBC and » Microsoft's SQL Server ODBC Driver for Linux." an ODBC Driver? Can't I use FreeTDS on Laravel?
Updated Native Client on Server with SQL 2008 to version 11.
I still have no success. can anybody help me?
After nearly two weeks of battle, I managed to resolve the issue!
I tried several ways to install the correct driver to make the connection to the bank could be established. I went to the depths looking to manually install pdodblib and make PHP understand that it needed to call FreeTDS through an ODBC connection to connect to the database. Unsuccessfully!
Until a light appeared at the end of the tunnel: a simple post on this blog seemed to mock me… But actually it brought me a simple solution.
Through HomeBrew I added two repositories containing the 'Formules' needed to re-compile PHP with MSSQL support.
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
Now we need to install PHP via the command:
brew install php55 --with-mssql
After completing the installation of all dependencies, all you have to do is configure your freetds.conf with the bank information and… Voilá! It works.