{"record":{"id":"d3f9f4dff4bcf98a","repo":"flarum/framework","slug":"please-specify-the-database-name","errorCode":null,"errorMessage":"Please specify the database name.","messagePattern":"Please specify the database name\\.","errorType":"validation","errorClass":"ValidationFailed","httpStatus":null,"severity":"error","filePath":"framework/core/src/Install/DatabaseConfig.php","lineNumber":60,"sourceCode":"    {\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\n        if (empty($this->schema) && $this->driver == 'pgsql') {\n            throw new ValidationFailed('Please specify the schema name.');\n        }\n\n        if (empty($this->username) && in_array($this->driver, ['mysql', 'mariadb', 'pgsql'])) {\n            throw new ValidationFailed('Please specify the username for accessing the database.');\n        }\n\n        if (! empty($this->prefix)) {\n            if (! preg_match('/^[\\pL\\pM\\pN_]+$/u', $this->prefix)) {\n                throw new ValidationFailed('The prefix may only contain characters and underscores.');\n            }\n\n            $maxPrefix = DatabaseRequirements::maxTablePrefixLength($this->driver);\n\n            if ($maxPrefix !== null && strlen($this->prefix) > $maxPrefix) {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Install/DatabaseConfig.php#L42-L78","documentation":"ValidationFailed thrown by DatabaseConfig::validate when the database name is empty. Unlike host/port, this applies to every driver including SQLite (where it is the database file path). The installer refuses to proceed without knowing which database to create/use.","triggerScenarios":"Constructing DatabaseConfig with an empty database name/path for any driver, e.g. missing DB_DATABASE value.","commonSituations":"Install form submitted with blank database field; .env missing DB_DATABASE; user expects the DB to be auto-created from a project name; SQLite path field left empty.","solutions":["Set the database property (or DB_DATABASE) to an existing database name the user can access.","Create the database on the server first, then supply its name.","For SQLite, set the database to the path of the .sqlite file to use."],"exampleFix":"// before\nnew DatabaseConfig(driver: 'mysql', host: 'db', port: 3306, database: '');\n// after\nnew DatabaseConfig(driver: 'mysql', host: 'db', port: 3306, database: 'flarum');","handlingStrategy":"validation","validationCode":"if (trim((string) $database) === '') {\n    throw new InvalidArgumentException('DB_DATABASE is required');\n}\n$config = new DatabaseConfig(driver: $driver, host: $host, port: $port, database: $database);","typeGuard":"function hasDatabase(array $cfg): bool {\n    return isset($cfg['database']) && is_string($cfg['database']) && trim($cfg['database']) !== '';\n}","tryCatchPattern":"try {\n    $config = new DatabaseConfig(...$input);\n} catch (ValidationFailed $e) {\n    if (str_contains($e->getMessage(), 'database name')) {\n        $errors['database'] = 'Database name is required.';\n    }\n}","preventionTips":["Mark the database field required in installer forms.","Pre-fill a sensible default database name.","Check the database exists (or the SQLite path is writable) before install."],"tags":["database","config","validation","install"],"backgroundTag":"empty-required-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"}