前提・実現したいこと
プログラミング初心者です。
現在、laravelの勉強の為、xampp環境でlaravelを動かして簡単な記事投稿サイトを作成しようとしています。
xamppにlaravelをインストールし、laravelのトップページを表示することはできました。
今、ログイン認証機能を実装するため、
composer require laravel/ui
php artisan ui vue --auth
npm install && npm run dev
の順にコマンドを実行し、auth関連のファイルを生成しました。
その後、php artisan migrate を実行してusers等のテーブルを作成しようとしましたが、could not find driver のメッセージが出てしまいテーブルが作成できませんでした。
発生している問題・エラーメッセージ
C:\xampp\htdocs\laravel-repo\laravel>php artisan migrate lluminate\Database\QueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = ■■■ and table_name = migrations and table_type = 'BASE TABLE') at C:\xampp\htdocs\laravel-repo\laravel\vendor\laravel\framework\src\Illuminate\Database\Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) { > 669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673| Exception trace: 1 PDOException::("could not find driver") C:\xampp\htdocs\laravel-repo\laravel\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=■■■", "■■■", "■■■", []) C:\xampp\htdocs\laravel-repo\laravel\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
※DB名、ユーザー名、パスワード等は伏せさせていただきます。
※作成したDBにはテーブルは作っておらず、空のDBとなっています。
試したこと
php.iniを開き
「extension=pdo_mysql」のコメントをはずす
「extension=php_pdo_mysql.dll」を追記
して、apacheを再起動
laravelのdatabase.phpのmySQLの部分を書き換え
'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', '■■■'), 'username' => env('DB_USERNAME', '■■■'), 'password' => env('DB_PASSWORD', '■■■'), 'unix_socket' => env('DB_SOCKET', ''), # 'charset' => 'utf8mb4', 'charset' => 'utf8', # 'collation' => 'utf8mb4_unicode_ci', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ],
laravelの.envファイルのDBの部分を書き換え
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=■■■ DB_USERNAME=■■■ DB_PASSWORD=■■■
補足情報(FW/ツールのバージョンなど)
■開発環境
windows 10 Pro
xampp version 7.4.2
php version 7.4.2
laravel version 6.15.1
参考書
「PHPフレームワーク Laravel入門第2版」
を参考にして勉強しています。
回答2件
あなたの回答
tips
プレビュー