{"record":{"id":"89af38fa261ebad2","repo":"flarum/framework","slug":"please-specify-a-database-driver","errorCode":null,"errorMessage":"Please specify a database driver.","messagePattern":"Please specify a database driver\\.","errorType":"validation","errorClass":"ValidationFailed","httpStatus":null,"severity":"error","filePath":"framework/core/src/Install/DatabaseConfig.php","lineNumber":44,"sourceCode":"        private readonly ?string $prefix\n    ) {\n        $this->validate();\n    }\n\n    public function toArray(): array\n    {\n        return array_merge([\n            'driver' => $this->driver,\n            'database' => $this->database,\n            'prefix' => $this->prefix,\n            'prefix_indexes' => true\n        ], $this->driverOptions());\n    }\n\n    private function validate(): void\n    {\n        if (empty($this->driver)) {\n            throw new ValidationFailed('Please specify a database driver.');\n        }\n\n        if (! in_array($this->driver, ['mysql', 'mariadb', 'sqlite', 'pgsql'])) {\n            throw new ValidationFailed('Currently, only MySQL, MariaDB, SQLite and PostgreSQL are supported.');\n        }\n\n        if (empty($this->host) && in_array($this->driver, ['mysql', 'mariadb', 'pgsql'])) {\n            throw new ValidationFailed('Please specify the hostname of your database server.');\n        }\n\n        if (($this->port < 1 || $this->port > 65535) && in_array($this->driver, ['mysql', 'mariadb', 'pgsql'])) {\n            throw new ValidationFailed('Please provide a valid port number between 1 and 65535.');\n        }\n\n        if (empty($this->database)) {\n            throw new ValidationFailed('Please specify the database name.');\n        }\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Install/DatabaseConfig.php#L26-L62","documentation":"DatabaseConfig::validate() requires a non-empty driver during construction. An empty driver means the installer could not determine which database type to configure, so ValidationFailed('Please specify a database driver.') is thrown.","triggerScenarios":"Constructing DatabaseConfig with driver '' or null; install input missing the 'driver' key so it defaults to empty.","commonSituations":"Automated/headless installs whose config file omits the database driver; interactive installs where the driver prompt value was dropped; copy-pasted config templates with the driver line removed.","solutions":["Set the driver explicitly to one of: mysql, mariadb, sqlite, pgsql","Add the missing driver key to the install configuration file","Re-run the installer interactively so the driver prompt is answered"],"exampleFix":"// before\n$configuration = ['host' => 'localhost', 'database' => 'forum'];\n// after\n$configuration = ['driver' => 'mysql', 'host' => 'localhost', 'database' => 'forum'];","handlingStrategy":"validation","validationCode":"if (empty($configuration['driver'])) {\n    throw new ValidationFailed('Please specify a database driver.');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $dbConfig = new DatabaseConfig($configuration);\n} catch (ValidationFailed $e) {\n    $output->writeln(\"<error>{$e->getMessage()}</error>\");\n    return Command::FAILURE;\n}","preventionTips":["Always include the 'driver' key in install configuration files","Use config templates that enumerate all required database keys","Pre-flight validate the config array before constructing DatabaseConfig"],"tags":["database","configuration","installation","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}