1

I'm trying to connect Laravel with a multiple sqlserver databases, I defined the connections on my database.php file correctly :

'connections' => [



    'sqlsrv' => [
        'driver' => 'sqlsrv',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '16000'),
        'database' => env('DB_DATABASE', 'dbname'),
        'username' => env('DB_USERNAME', 'me'),
        'password' => env('DB_PASSWORD', 'me'),
        'charset' => 'utf8',
        'prefix' => '',
        'prefix_indexes' => true,
    ],
    'sqlsrv2' => [
        'driver' => 'sqlsrv',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '16000'),
        'database' => env('DB_DATABASE_2', 'dbname2'),
        'username' => env('DB_USERNAME', 'me'),
        'password' => env('DB_PASSWORD', 'me'),
        'charset' => 'utf8',
        'prefix' => '',
        'prefix_indexes' => true,
    ],

],

and set my .env file

DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
DB_PORT=16000
DB_DATABASE=dbname
DB_USERNAME=me
DB_PASSWORD=me

I try to verify the connectivity to my sql server database from another application and it's working perfectly. then I created a model on my laravel application and once I type php artisan migrate I get this error : enter image description here

anyone can help to resolve this problem ?

UPDATE !

After adding pdo sqlsrv extensions to my ext folder and my php.ini i get this error : [![enter image description here][2]][2]

[![enter image description here][3]][3]

UPDATE 3 :

After installing odbc 13 i got this problem enter image description here

2
  • try php artisan cache:clear, php artisan config:clear Commented Dec 19, 2018 at 10:52
  • I still get the error :( Commented Dec 19, 2018 at 11:02

1 Answer 1

3

Ah, WAMPServer has 2 seperate php.ini files.

One is used by PHP under Apache and the other by the PHP CLI.

I see you are using the CLI, so you need to check that you have included the SQL Server drivers extension in the CLI php.ini file.

You will find that in:

C:\wamp64\bin\php\php{version}\php.ini

You have to edit this manually, there is no menu link to do this, the menu link to edit the php.ini only edits the PHP under Apache version of php.ini

Make sure you edit the php.ini file in the folder that matches the version of PHP you are actually using for this project, as of course you can have multiple versions of PHP installed under WAMPServer

UPDATE: Second Problem

You have added the 32bit AND 64 bit SQL Server drivers to your ext folder!

Your WAMPServer menu shows

1. php_sqlsrv_72_ts_x64 
2. php_sqlsrv_72_ts_x32
3. php_pdo_sqlsrv_72_ts_x64 
4. php__pdo_sqlsrv_72_ts_x32

as you are using 64 bit wamp, you should only have these 2

1. php_sqlsrv_72_ts_x64 
2. php_pdo_sqlsrv_72_ts_x64 
Sign up to request clarification or add additional context in comments.

12 Comments

I've just added the extensions to ext folder of my php and i edited my php.ini but i get an error saying: no 'extension' = and it show the extensions that i've just added
Show that error in your question, after a line with UPDATE in it
I added only the 64 bit version still get the problem
I've updated the question with the problem i've got after adding the extension in phpforapache.ini too
Phew, thats a relief. I was running out of ideas :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.