Symfony : how to set SSL parameters in Doctrine DBAL configuration (YAML)?

后端 未结 6 1889
误落风尘
误落风尘 2021-02-09 10:56

I\'d like to add my SSL cert and key files to Doctrine DBAL configuration but I don\'t see how to achieve that.

In PHP, I just have to write something like :

<         


        
6条回答
  •  自闭症患者
    2021-02-09 11:13

    Now in 2020, with Symfony > 4.2, the solution is :

    # Doctrine Configuration
    doctrine:
        dbal:
            driver:   pdo_mysql
            host:     "%database_host%"
            port:     "%database_port%"
            dbname:   "%database_name%"
            user:     "%database_user%"
            password: "%database_password%"
            charset:  UTF8
            # Options for SSL connection
            options:
                !php/const PDO::MYSQL_ATTR_SSL_CA : %ca_cert%
                !php/const PDO::MYSQL_ATTR_SSL_KEY : %private_key%
                !php/const PDO::MYSQL_ATTR_SSL_CERT : %public_cert%
    

    Source : symfony.com/doc/4.2/service_container/parameters.html

    Tested with Symfony 5.1.8

提交回复
热议问题