SetupDatabaseService

Service class helping to manage database related settings and operations required to set up TYPO3

Internal

This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API.

Tags
phpstan-import-type

Params from DriverManager

Attributes
#[Autoconfigure]
$public: true

Table of Contents

Properties

$validDrivers  : array

Methods

__construct()  : mixed
checkDatabaseRequirementsForDriver()  : FlashMessageQueue
checkDatabaseSelect()  : bool
checkExistingDatabase()  : FlashMessage
Checks whether an existing database on the default connection can be used for a TYPO3 installation. The database name is only persisted to the local configuration if the database is empty.
checkRequiredDatabasePermissions()  : array
createDatabase()  : void
createNewDatabase()  : FlashMessage
Creates a new database on the default connection
getBackendUserPasswordValidationErrors()  : array
getDatabaseConfigurationFromEnvironment()  : array
Try to fetch db credentials from a .env file and see if connect works
getDatabaseConfiguredMysqliSocket()  : string
Returns configured socket, if set.
getDatabaseConfiguredPdoMysqlSocket()  : string
Returns configured socket, if set.
getDatabaseList()  : array
Returns list of available databases (with access-check based on username/password)
getDriverOptions()  : array
importDatabaseData()  : FlashMessage[]
Create tables and import static rows
isDatabaseConfigurationComplete()  : bool
Check system/settings.php for required database settings: - 'username' and 'password' are mandatory, but may be empty - if 'driver' is pdo_sqlite and 'path' is set, its ok, too
isDatabaseConnectSuccessful()  : bool
Test connection with given credentials and return exception message if exception thrown
isValidDbHost()  : bool
isValidDbName()  : bool
isValidDbPort()  : bool
markWizardsDone()  : void
setDefaultConnectionSettings()  : array{0: bool, 1: FlashMessage[], 2: array}

Properties

$validDrivers

protected array $validDrivers = ['mysqli', 'pdo_mysql', 'pdo_pgsql', 'pdo_sqlite']

Methods

checkDatabaseSelect()

public checkDatabaseSelect() : bool
Return values
bool

checkExistingDatabase()

Checks whether an existing database on the default connection can be used for a TYPO3 installation. The database name is only persisted to the local configuration if the database is empty.

public checkExistingDatabase(string $dbName) : FlashMessage
Parameters
$dbName : string

name of the database

Return values
FlashMessage

checkRequiredDatabasePermissions()

public checkRequiredDatabasePermissions() : array
Return values
array

createDatabase()

public createDatabase(string $name) : void
Parameters
$name : string
Tags
throws
Exception

createNewDatabase()

Creates a new database on the default connection

public createNewDatabase(string $dbName) : FlashMessage
Parameters
$dbName : string

name of database

Return values
FlashMessage

getBackendUserPasswordValidationErrors()

public getBackendUserPasswordValidationErrors(string $password) : array
Parameters
$password : string
Return values
array

getDatabaseConfigurationFromEnvironment()

Try to fetch db credentials from a .env file and see if connect works

public getDatabaseConfigurationFromEnvironment() : array
Return values
array —

Empty array if no file is found or connect is not successful, else working credentials

getDatabaseConfiguredMysqliSocket()

Returns configured socket, if set.

public getDatabaseConfiguredMysqliSocket() : string
Return values
string

getDatabaseConfiguredPdoMysqlSocket()

Returns configured socket, if set.

public getDatabaseConfiguredPdoMysqlSocket() : string
Return values
string

getDatabaseList()

Returns list of available databases (with access-check based on username/password)

public getDatabaseList() : array
Tags
throws
Exception
Return values
array —

List of available databases

getDriverOptions()

public getDriverOptions() : array
Return values
array

isDatabaseConfigurationComplete()

Check system/settings.php for required database settings: - 'username' and 'password' are mandatory, but may be empty - if 'driver' is pdo_sqlite and 'path' is set, its ok, too

public isDatabaseConfigurationComplete() : bool
Return values
bool —

TRUE if required settings are present

isDatabaseConnectSuccessful()

Test connection with given credentials and return exception message if exception thrown

public isDatabaseConnectSuccessful() : bool
Return values
bool

isValidDbHost()

public isValidDbHost(string $name) : bool
Parameters
$name : string
Return values
bool

isValidDbName()

public isValidDbName(string $name) : bool
Parameters
$name : string
Return values
bool

isValidDbPort()

public isValidDbPort(int $number) : bool
Parameters
$number : int
Return values
bool

markWizardsDone()

public markWizardsDone(ContainerInterface $container) : void
Parameters
$container : ContainerInterface

setDefaultConnectionSettings()

public setDefaultConnectionSettings(array $values) : array{0: bool, 1: FlashMessage[], 2: array}
Parameters
$values : array
Return values
array{0: bool, 1: FlashMessage[], 2: array} —

Success state, messages and the default connection settings written to the configuration

On this page

Search results