PHP Manual
/
Doctrine

Configuring the Baraja Doctrine connection

10. 09. 2020

To establish a connection to the database within [Baraja Doctrine](https://github.com/baraja-core/doctrine) you need to use the Neon configuration file, which is a common part of the Nette framework.

The configuration can look like this:

baraja.database:
connection:
host: localhost
dbname: my-database
user: root
password: ******

When the DI Container is compiled, the configuration is checked for correctness and an error message is thrown describing the specific error.

The login credentials are securely verified when compiling the container and then physically stored in the container. Only the service providing the connection to the database then has access to the logins, and they cannot simply be obtained by an external service or a rogue visitor from the Tracy bar.

Backward compatibility

In the past, definitions using parameters were used, for example:

``neon parameters: database: primary: host: localhost ...


However, this setting is marked as **deprecated** to increase application security. This is because when using the parameters, any service (or even part of the application) could request login credentials, or the active Tracy bar on the page could give them away.

Jan Barášek   Více o autorovi

Autor článku pracuje jako seniorní vývojář a software architekt v Praze. Navrhuje a spravuje velké webové aplikace, které znáte a používáte. Od roku 2009 nabral bohaté zkušenosti, které tímto webem předává dál.

Rád vám pomůžu:

Související články

1.
Status:
All systems normal.
2024