Reputation: 6133
After installing the dll's
to use with MSSqL server, the command php artisan migrate
ran correctly and the tables were made in the db
. So I thought the connection would work for this application.
I then used the command php artisan make:auth
(which doesn't use the db connection) to scaffold the authentication files.
Now when I try to register anyone I get errors:
PDOExeption (1/2)
Could not find driver
and
PDOExeption (2/2)
Could not find driver (select count(*) from .....
Now I tried to see if using the cli
commands still work and both php artisan migrate:rollback
and php artisan migrate
still work.
Environment: Windows 7 with xampp installed. Versions: Laravel 5.4, php 7.1
Not that it matters but here are parts of my .env
and database.php
files:
`database.php`
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '10.0.0.40'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'sqlcon'),
'username' => env('DB_USERNAME', 'sa'),
'password' => env('DB_PASSWORD', 'test'),
'charset' => 'utf8',
'prefix' => '',
],
`.env`
DB_CONNECTION=sqlsrv
DB_HOST=10.0.0.40
DB_PORT=1433
DB_DATABASE=sqlcon
DB_USERNAME=sa
DB_PASSWORD=test
So how come the cli
commands work and the browser don't?
Doesn't laravel use the same config for both cli
and browser connections?
Update: added some extra info
C:\xampp\htdocs\sqlcon>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\xampp\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Used this to show my php configuration and it shows:
Loaded Configuration File C:\xampp\php\php.ini
The php -m command shows:
C:\xampp\htdocs\sqlcon>php -m
[PHP Modules]
bcmath
...(some others)
pdo_mysql
pdo_sqlite
pdo_sqlsrv (this one is enabled)
Phar
...
[Zend Modules]
According to php -m
the pdo_sqlsrv
is enabled, but I can't find any reference to it in the phpinfo
page.
Upvotes: 2
Views: 1571
Reputation: 943
I had the same issue and I have solved as follow (WAMP):
You should download following 2 .dll files.
You have to concern about:
(My Case: Windows 7 64bit / PHP 7 / Thread Safe -> _7_ts_x64)
Put those downloaded 2 .dll files into wamp64\bin\php\php*\ext
Type following code after default extensions:
extension=php_pdo_sqlsrv_7_ts_x64.dll
extension=php_sqlsrv_7_ts_x64.dll
in following files:
wamp64\bin\apache\apache*\bin\php.ini
wamp64\bin\php\php*\php.ini
wamp64\bin\php\php*\phpForApache.ini
Upvotes: 4
Reputation: 6133
When installing the driver in php.ini
I used the following line as this was the name of the file in the extension directory (extension_dir="C:\xampp\php\ext"
):
extension=php_pdo_sqlsrv_71_ts.dll
Changing both the name of the file in this directory and the reference to it in the php.ini
file and restarting apache
solved the problem.
So now the file is php_pdo_sqlsrv.dll
and the reference is:
extension=php_pdo_sqlsrv.dll
Installing this after downloading the dlls
and making the change to php.ini
.
Don't forget to restart apache
.
Upvotes: 1