Reputation: 93
I'm trying to connect to a Microsoft SQL Server using Laravel.
I've got two PHP folders in my wamp64/bin/php
directory, one for version 5.6, and one for version 7.
I downloaded and installed the drivers in the ext/
folder of both of these directories.
Likewise, I've got two php.ini
files...and a third one, which I think is a shortcut.
1) wamp64/bin/apache/apache2.4.23/bin/php.ini
... and the two others exist in the respective PHP folders mentioned above (one for version 5, and one for version 7)
I've pasted the following in all of those:
extension=php_sqlsrv_56_ts.dll
extension=php_pdo_sqlsrv_56_ts.dll
However, upon attempting to do anything with the database, Laravel gives me the following error in the logs:
'PDOException' with message 'could not find driver' in C:\wamp64\www\projects\{project}\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68
I've restarted WAMP several times after making changes, and I'm not sure why the application won't communicate with the database.
I've also checked the .env
as well as the default
value in database.php
I don't know what's going on, and I am looking for some guidance in this issue.
Thanks! :)
Upvotes: 0
Views: 672
Reputation: 93
This was quite confusing, and honestly there doesn't seem to be nearly enough information on this. Videos, articles, blog posts etc. I didn't find anything accurate.
Anyway this is what worked for me, and I'll probably make a start-to-end tut on YouTube...
This assumes that you're oke with using PHP7
1) Download WAMP32-Bit, important: run the installation as administrator.
2) Download the PHP SQL Driver (4.0) (or an other version if you don't want to use PHP 7)
3) Extract the drivers into /wamp/bin/php/7.x.xx/ext/
directory
4) Using the wamp aestan tray menu, open php.ini
- add the following two lines:
extension=php_sqlsrv_7_ts_x86.dll
extension=php_pdo_sqlsrv_7_ts_x86.dll
I understand that some extensions rely on others, and thus they need to be placed in specific orders, for that reason I should mention that I pasted these two right below the following extension:
;extension=php_pdo_pgsql.dll
which, as you see, is commented out.
Next, restart wamp and you should hopefully be all set. On http://localhost
where you see the list of extensions, you should see sqlsrv
somewhere in there.
Hope this helps someone.
Upvotes: 0
Reputation: 27553
first of all from wamp icon you need to select the version of php, then go to that php.ini and the remove the ; from the 2 lines you posted, there is no need of adding another php.ini after removing ; restart your wap server
hope it helps
Upvotes: 1