问题
I'm trying to set up a development environment after not having done web dev in over a year. I've installed php 7.2.7 on my computer, then installed composer and WAMP.
I'm using php artisan serve to set up a local server. I'm trying to create a new user in my database's 'users' table, using the following code in my web.php (routes) file.
Route::get('/new', function(){
User::create([
'password' => Hash::make('anything'),
'firstname' => 'Nick',
'lastname' => 'xyz',
'email' => 'xyz@ph.com',
'roleflag' => 0
]);
});
But am getting the following error:
This seems to be a pretty common error, and I have found help on other stackoverflow/laracasts posts such as:
Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL
and
https://laracasts.com/discuss/channels/general-discussion/cant-connect-to-sql-server-could-not-find-driver
I've thus uncommented the two lines from my php.ini file, changed my .env and config/database.php file to have appropriate settings/connection values, etc. but still receive this error.
Relevant config.php code:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('venturebreeder', 'forge'),
'username' => env('root', 'forge'),
'password' => env('', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
I'm a bit slower at troubleshooting since it has been a while since I've done this -- can anyone see what I'm doing wrong? Help much appreciated.
回答1:
What lines did you uncomment in php.ini file?
Do you have the pdo_mysql extension installed?
Remove the ; from ;extension=pdo_mysql.so and restart your WAMP server
Source: https://stackoverflow.com/a/35240511/6385459
来源:https://stackoverflow.com/questions/51486940/laravel-could-not-find-driver-sql-insert-into