Laravel migration cannot find driver when using sqlsrv database in windows - laravel

I am using sqlsrv database connection in my project as I need to connect to Microsoft SQL Database.
I have successfully installed the sqlsrv driver because I can connect to the Database to retrieve data.
But when I try to do the Laravel Migration, it shows an error:
Illuminate\Database\QueryException : could not find driver (SQL: select * from sysobjects where type = 'U' and name = migrations)
Below is my .env
DB_CONNECTION=sqlsrv
DB_HOST=**********.database.windows.net
DB_PORT=1433
DB_DATABASE=****************_4cd1_9d18_2a7d9ddbcd13
DB_USERNAME=***************_4cd1_9d18_2a7d9ddbcd13_ExternalWriter
DB_PASSWORD=***************
php.ini
extension=php_xmlrpc.dll
extension=php_xsl.dll
extension=php_pdo_sqlsrv_7_nts_x64.dll
extension=php_pdo_sqlsrv_7_nts_x86.dll
extension=php_pdo_sqlsrv_7_ts_x64.dll
extension=php_pdo_sqlsrv_7_ts_x86.dll
extension=php_pdo_sqlsrv_71_nts_x64.dll
extension=php_pdo_sqlsrv_71_nts_x86.dll
extension=php_pdo_sqlsrv_71_ts_x64.dll
extension=php_pdo_sqlsrv_71_ts_x86.dll
extension=php_sqlsrv_7_nts_x64.dll
extension=php_sqlsrv_7_nts_x86.dll
extension=php_sqlsrv_7_ts_x64.dll
extension=php_sqlsrv_7_ts_x86.dll
extension=php_sqlsrv_71_nts_x64.dll
extension=php_sqlsrv_71_nts_x86.dll
extension=php_sqlsrv_71_ts_x64.dll
extension=php_sqlsrv_71_ts_x86.dll

How to use SQL Server DLL files with PHP 7.2 version on xampp
https://github.com/Microsoft/msphpsql/releases
To download Windows DLLs for PHP 7.1 or above from the PECL repository, please go to the SQLSRV or PDO_SQLSRV PECL page.
https://pecl.php.net/package/sqlsrv/5.6.1/windows
https://pecl.php.net/package/pdo_sqlsrv/5.6.1/windows
NOTE: Do not forget to remove 'php_' prefix when you add extension dll filename in php.ini file. eg.
extension=pdo_sqlsrv
extension=sqlsrv
Do not change actual filename which you put in /xampp/php/ext/ directory.
"7.2 Thread Safe (TS) x86" worked for me for 'sqlsrv' and 'pdo_sqlsrv' extensions.
Restart xampp or apache then you can see enabled 'pdo_sqlsrv' extension when you print phpinfo() in a test php file
It was very hard to find this solution. I hope, this will also help you. All the best :)

You may need to upgrade your PHP version to PHP 7.1.
Now make sure that the files config/database.php and .env are configured properly.
See this one: https://laracasts.com/discuss/channels/general-discussion/connect-laravel-to-microsoft-sql

After fighting with it for a while found a solution :
you need to downloaded it from here then extract the files in your php folder

For PHP 7.4 on Windows 10 (x64), I've solved same error s below:
Downloaded the driver from
https://www.microsoft.com/en-us/download/details.aspx?id=20098
Extracted the archive and copied the file
php_pdo_sqlsrv_74_ts_x64.dll to the ext folder (C:\Program Files\php74\ext in my setup)
Added extension=php_pdo_sqlsrv_74_ts_x64.dll into php.ini file
In my .env file I've DB_CONNECTION=sqlsrv so I first thought php_sqlsrv_74_ts_x64.dll should be used but it didn't work.

Related

after Update laravel 6.2 [App\Http\Controllers\Auth\ConfirmPasswordController] does not exist

I update laravel from v 6.0 to v6.2 and after the finish, I try php artisan route:list
This error
I had the same issue, i fixed it with the following solution:
Create a empty file named "ConfirmPasswordController.php" in the folder App/Http/Controllers/Auth
Go to https://github.com/laravel/laravel/tree/master/app/Http/Controllers/Auth en open the file named "ConfirmPasswordController.php"
Copy all the file contents to your newly created file and save it.
This should fix the error.
Edit
The problem is, were updating the composer dependencies, but not the core application. But de composer dependencies expect you to update the core. They refer to files on the core application that not exists (because the application is not up-to-date).
See: How to update Laravel Application (not the composer dependencies)
This has been fixed. Just update to Laravel 6.4
Step1. Create ConfirmPasswordController.php file in app/Http/Controllers/Auth/ path.
Step2. ConfirmPasswordController.php paste this content to ConfirmPasswordController.php file.
From v6.0.0 to v6.2.0 the following addition and modifications were made.
Added app/Http/Controllers/Auth/ConfirmPasswordController.php
Modified app/Http/Controllers/Auth/ForgotPasswordController.php
Modified app/Http/Controllers/Auth/ResetPasswordController.php
Modified app/Http/Kernel.php
Modified config/auth.php
Modified resources/lang/en/validation.php
You can see the diff of v6.0.0 to v6.2.0 here.
Create ConfirmPasswordController.php manually and It's may be duplicate of - duplicate
1 ) Open file vender/laravel/framework/src/Illuminate/Routing/Router.php".
2 ) and comment these
// $this->get('password/confirm', 'Auth\ConfirmPasswordController#showConfirmForm')->name('password.confirm');
// $this->post('password/confirm', 'Auth\ConfirmPasswordController#confirm');

Windows 10 PDOException with message 'could not find driver' Laravel 5.6.33 Wampserver 3.1.7 x86

I know there is a lot on this topic around StackOverflow, but my problem is that i have php extensions already uncommented, i have made the required changes to database.php and .env and i have declared and used the necessary environment path. The only thing i haven't done is install composer due to my proxy restrictions. I have a proxy that is over a kerberos windows AD, and for some reason nothing that used to work with proxy address, port and credentials (user and password) is working anymore, so i found this website to download php libraries and its dependencies without composerand managed to get Laravel 5.6.33 working or at least apparently, becouse when i tried to call:
C:\wamp\www\laravel> php artisan migrate:install i got the following error :Illuminate\Database\QueryException : could not find driver (SQL: create table "migrations" ("id" serial primary key not null, "migration" varchar(255) not null, "batch" integer not null))and the following Exception trace: `Exception trace:
1 PDOException::("could not find driver")
C:\wamp\www\laravel\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68
2 PDO::__construct("pgsql:host=localhost;dbname=tienda;port=5432", "postgres", "admin123", [])
C:\wamp\www\laravel\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68`
I have to say that i am working on windows 10 Version 10.0.17134.1 64 bits and my wamp server is 3.1.7 with php 7.2.14
Any help or pointer on this issue will be appreciated
After a lot of research and frustration, I thought on give it a try to xampp and what I found was that with xampp xampp-win32-7.3.0-0-VC15.exe installed, the correct extensions enabled in the php.ini
extension=pdo_pgsql
extension=pgsql
which in the xamp case is located at
C:\xampp\php
I set the path for xampp php in my Windows 10 Ent it is C:\xampp\php and later run the command
php C:\wamp\www\laravel> php artisan tinker
, after in the tinker console run
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> DB::connection()->getPdo()
And I got what I was hoping for:
=> PDO {#2863
inTransaction: false,
attributes: {
CASE: NATURAL,
ERRMODE: EXCEPTION,
PERSISTENT: false,
DRIVER_NAME: "pgsql",
SERVER_INFO: "PID: 1764; Client Encoding: UTF8; Is Superuser: on; Session Authorization: postgres; Date Style: ISO, MDY",
ORACLE_NULLS: NATURAL,
CLIENT_VERSION: "9.6.9",
SERVER_VERSION: "9.6.11",
STATEMENT_CLASS: [
"PDOStatement",
],
EMULATE_PREPARES: false,
CONNECTION_STATUS: "Connection OK; waiting to send.",
DEFAULT_FETCH_MODE: BOTH,
},
}
A response, which means that it found the driver that was always there and was able to use to access the database which was already installed and running.
The rest settings done in wamp with the virtual host and extensions enabled with the PHP version of 7.3.1 are the same and work like a charm.
I hope this may help others until the wamp and laravel teams find a way to make laravel
php artisan migrate
the command to work with wamp 3.1.7 for the x86 architecture alone.

Laravel pdf issue: failed to open stream: No such file or directory by using barryvdh/laravel-dompdf package

I am update composer and use barryvdh/laravel-dompdf package.
the problem is when i click the button it show me error like image below:-
Is that anyway to change the folder path? or am I missing code to modify path to download the pdf file?
You need to run this command:
php artisan vendor:publish
Then, try to create a fonts directory in the storage directory.
i.e. storage/app/fonts. Also, remember to make it writable.
For maximum execution time of 30 seconds exceeded, this is not laravel related issue but it's about php configuration issue. Please see this and fix it: http://php.net/manual/en/info.configuration.php#ini.max-execution-time
You can also see this answer: https://stackoverflow.com/a/30290770/6000629
Hope this will helps you!
Try this:
$pdf = PDF::loadView('pdf/personalpdf', compact('user','result'))->setOptions(['defaultFont' => 'sans-serif']);
It worked for me, I didn't make any file/folder
Just remove the reference to css external file in your cart.placeOrder.blade
Note: This directory must exist and be writable by the webserver process.
under the config file thats what it say: therefore you should create the fonts directory inside the storage.
"font_cache" => storage_path('fonts/'),

Auth guard driver [api] is not defined?

I use this library jwt-auth-guard in Laravel 5.3.
When I try open page I get error:
InvalidArgumentException in AuthManager.php line 99:
Auth guard driver [api] is not defined.
How can I fix it? I made everything that was need
I'm not sure, please check you guard driver setup into config/auth.php first. You can cross check this from GIT repo.
Let me know if any concern from above.
If you are using tymondesigns/jwt-auth package first check that you are downloading the latest version (1.0.0-rc.2 for this time) or you can just update your composer
composer update
and also delete your old jwt file from config folder and publish again also run!
php artisan jwt:secret

installation - PHP Extensions "pdo_mysql" must be loaded

This is whay i see on phpinfo();
pdo_mysql
PDO Driver for MySQL enabled
Client API version 5.1.68
Directive Local Value Master Value
pdo_mysql.default_socket /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock
but im still getting the magento message :
"PHP Extensions "pdo_mysql" must be loaded"
why is that ?
open or make php.ini file into root directory and add the following code:
extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so

Resources