Skip to content

Commit 1b5859a

Browse files
committed
Minor tweaks
1 parent c51bc3a commit 1b5859a

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

reference/configuration/doctrine.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,9 @@ the path of the bundle.
473473
SSL Connection with MySQL
474474
~~~~~~~~~~~~~~~~~~~~~~~~~
475475

476-
If you want to configure a secure SSL connection to MySQL in your Symfony application using Doctrine, you need to set specific options for the SSL certificates. Here's how to configure the connection using environment variables for the certificate paths:
476+
To securely configure an SSL connection to MySQL in your Symfony application
477+
with Doctrine, you need to specify the SSL certificate options. Here's how to
478+
set up the connection using environment variables for the certificate paths:
477479

478480
.. configuration-block::
479481

@@ -516,7 +518,27 @@ If you want to configure a secure SSL connection to MySQL in your Symfony applic
516518
</doctrine:config>
517519
</container>
518520
519-
Make sure that your environment variables are correctly set in your ``.env.local`` or ``.env.local.php`` file as follows:
521+
.. code-block:: php
522+
523+
// config/packages/doctrine.php
524+
use Symfony\Config\DoctrineConfig;
525+
526+
return static function (DoctrineConfig $doctrine): void {
527+
$doctrine->dbal()
528+
->connection('default')
529+
->url(env('DATABASE_URL')->resolve())
530+
->serverVersion('8.0.31')
531+
->driver('pdo_mysql');
532+
533+
$doctrine->dbal()->defaultConnection('default');
534+
535+
$doctrine->dbal()->option(\PDO::MYSQL_ATTR_SSL_KEY, '%env(MYSQL_SSL_KEY)%');
536+
$doctrine->dbal()->option(\PDO::MYSQL_SSL_CERT, '%env(MYSQL_ATTR_SSL_CERT)%');
537+
$doctrine->dbal()->option(\PDO::MYSQL_SSL_CA, '%env(MYSQL_ATTR_SSL_CA)%');
538+
};
539+
540+
Ensure your environment variables are correctly set in the ``.env.local`` or
541+
``.env.local.php`` file as follows:
520542

521543
.. code-block:: bash
522544

0 commit comments

Comments
 (0)