0

i'm running Laravel with the xampp terminal(i executed xampp as Administrator ), my connection sqlsrv is working with a normal php script but not with laravel. i have xampp with php 7.3 and the last version of laravel. what i'm missing?? i configured .env with my connection parameeters:

DB_CONNECTION=sqlsrv
DB_HOST=mydomain.com
DB_PORT=1433
DB_DATABASE=xxxxx
DB_USERNAME=xxxxx
DB_PASSWORD=xxxxx

and config/database.php

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
              'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
        ],

when i try to execute php artisan migrate i get this error:

could not find driver (SQL: select * from sysobjects where type = 'U' and name = migrations)  
 at C:\xampp\htdocs\m2connector\vendor\laravel\framework\src\Illuminate\Database\Connection.php:665
    661|         // If an exception occurs when attempting to run a query, we'll format the error
    662|         // message to include the bindings with SQL, which will make this exception a
    663|         // lot more helpful to the developer instead of just the database's errors.
    664|         catch (Exception $e) {
  > 665|             throw new QueryException(
    666|                 $query, $this->prepareBindings($bindings), $e
    667|             );
    668|         }
    669|

  Exception trace:

  1   PDOException::("could not find driver")
      C:\xampp\htdocs\m2connector\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70

  2   PDO::__construct("dblib:host=xxxxxx:1433;dbname=xxxxx;charset=utf8mb4", "xxxxx", "xxxxxx", [])
      C:\xampp\htdocs\m2connector\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70

  Please use the argument -v to see more details.
Ossama
  • 19
  • 1
  • 7
  • Can you run the command `php artisan cache:clear` and `php artisan serve` – Jithesh Jose Nov 06 '19 at 11:07
  • Does this answer your question? [Laravel to SQL Server (sqlsrv). \[PDOException\] could not find driver](https://stackoverflow.com/questions/39860273/laravel-to-sql-server-sqlsrv-pdoexception-could-not-find-driver) – Salim Djerbouh Nov 06 '19 at 11:10
  • Your PHP Driver for SQL Server (`sqlsrv` PHP extension) is not installed. This [answer](https://stackoverflow.com/questions/53664188/how-to-connect-sql-server-with-php-using-xampp/53680488#53680488) may help. – Zhorov Nov 06 '19 at 13:11
  • No, i already tested the connection with a php script and every thing is working fine @zhorov – Ossama Nov 06 '19 at 15:19
  • my problem connection still only with Laravel! – Ossama Nov 07 '19 at 14:58
  • Try setting the port in your env to null. https://stackoverflow.com/a/64553358/9822705 – Nkwaten Oct 27 '20 at 11:28

0 Answers0