skip to Main Content

What should I do?

PHP8.2.13(cli)
Windows(WSL) Ubuntu20.04
Composer version 2.2.0

$ php artisan cache:clear

   PDOException 

  could not find driver

  at vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
     66▕         if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
     67▕             return new PDOConnection($dsn, $username, $password, $options);
     68▕         }
     69▕
  ➜  70▕         return new PDO($dsn, $username, $password, $options);
     71▕     }
     72▕
     73▕     /**
     74▕      * Determine if the connection is persistent.

      +10 vendor frames 
  11  [internal]:0
      KrloveEloquentModelGeneratorTypeRegistry::__construct()

      +15 vendor frames 
  27  [internal]:0
      IlluminateContainer

      Container::IlluminateContainer{closure}()

2

Answers


  1. Chosen as BEST ANSWER

    I deleted scripts section in composer.json.

    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    

  2. PHP cannot find the appropriate database driver to connect to your database.

    1. Install the PDO Extension for Your Database:
    • For MySQL: Install the pdo_mysql extension.
    • For PostgreSQL: Install the pdo_pgsql extension.
    1. Ensure the appropriate extension is enabled in your php.ini file.
    • For MySQL: extension=pdo_mysql
    • For PostgreSQL: extension=pdo_pgsql
    1. Restart your web server.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search