Slim2 : could not find driver

Hello everybody,

I’m facing a problem with my slim 2 application and I hope that any of you can point me in the right direction,.

I’m developing an angularjs solution and my development enviroment is this :

windows 8.1
php 5.6 ( x86-NTS-VC11)
ms sql server 2014 express

I have developed my api with Slim 2 and it’s working fine when I query my database (GET).
When I going to make an update (PUT) I get an error ( “could not find driver”) in my db connection function (new PDO…).

function getConnection() {
$serverName = “(local)\sqlexpress”;
$conn = new PDO( “sqlsrv:server=$serverName ; Database=mydatabase”, “myuser”, “mypassword”);
return $conn;

I call the same function for my GET requests and it works nicely.
I’m not an MS SQL expert but it seems to me that the user owns all the permissions to update the table.

Should I change my connection string?
Is Slim acting different if the connection is opened for a PUT operations ?

Thanks a lot

I have no experience with ms sql server, but I doubt this issue has anything to do with Slim. There is no relation between the request method and a pdo connection.

Is it possible that you’re not using the database when calling the GET route (cache maybe)?

That error means that you don’t have pdo_mysql.
Look in phpinfo() for pdo_mysql, PDO Driver for MySQL, maybe you have it installed but disabled

Anyway with phpinfo you should see if something is not being loaded for some reason

Thanks for the replies.

I confirm that I’m able to query the MS SQL database with GET request.
I have also updated some data inside a GET request, so I’m sure that my drivers are ok.
The problem arise only when I create the PDO inside a PUT request.
In example I wrote this test function:

$app->put('test_put/:id, function($id){
   echo "test_put";

and I get this message with postman:

Slim Application Error
The application could not run because of the following error:

Message: could not find driver


Line: 511


C:\inetpub\wwwroot\api\api.php(511): PDO->__construct('sqlsrv:server=(...', 'myuser', 'mypassword')
#1 C:\inetpub\wwwroot\api\api.php(28): getConnection()
#2 [internal function]: {closure}('1')
#3 C:\inetpub\wwwroot\api\Slim\Route.php(468): call_user_func_array(Object(Closure), Array)
#4 C:\inetpub\wwwroot\api\Slim\Slim.php(1357): Slim\Route->dispatch()
#5 C:\inetpub\wwwroot\api\Slim\Middleware\Flash.php(85): Slim\Slim->call()
#6 C:\inetpub\wwwroot\api\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call()
#7 C:\inetpub\wwwroot\api\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#8 C:\inetpub\wwwroot\api\Slim\Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
#9 C:\inetpub\wwwroot\api\api.php(32): Slim\Slim->run()
#10 {main}

Just to inform you that I finally found the cause of the problem.
As rightly noted JoeBengalen Slim has nothing to do with the problem.
After successfully configuring the Handler Mappings in IIS 7 now everything works perfectly.
For reference :