title: Symfony 4 Flex Database connection using `urlencode`
body: <p>I am starting a new project using Symfony 4 + Flex. At this time I'm trying to connect my new app to a MySQL database.</p>
  <p>I'm following the <a href="https://symfony.com/doc/current/doctrine.html#configuring-the-database" rel="nofollow noreferrer">Symfony Documentation</a>, and I have already add <code>doctrine</code> to my dependencies :</p>
  <pre><code>composer require doctrine
  composer require maker --dev
  </code></pre>
  <p>Then I've added the database connection information in the environment variable <code>DATABASE_URL</code> defined inside <code>.env</code> like this :</p>
  <pre><code>###&gt; doctrine/doctrine-bundle ###
  DATABASE_URL=mysql://myUser:myPasswordWithSpecialChars@127.0.0.1:3306/myDbName
  ###&lt; doctrine/doctrine-bundle ###
  </code></pre>
  <p>At this point I am facing an issue :</p>
  <blockquote>
  <p>DBALException</p>
  <p>Malformed parameter &quot;url&quot;.</p>
  </blockquote>
  <p>I'm thinking this is caused by the fact that my MySQL password is using some special characters. The documentation is talking about it :</p>
  <blockquote>
  <p>If the username, password or database name contain any character considered special in a URI (such as !, @, $, #), you must encode them. See RFC 3986 for the full list of reserved characters or use the urlencode function to encode them.</p>
  </blockquote>
  <p>I don't really understand how or where to use the <a href="https://secure.php.net/manual/en/function.urlencode.php" rel="nofollow noreferrer">urlencode</a> function because the <code>.env</code> file is not a PHP one (as <code>doctrine.yaml</code>).</p>
  <p>Is someone have already use the <code>urlencode</code> function to encode a MySQL password containing special chars ?</p>
  <p>Thanks.</p>
  <p><strong>EDIT</strong></p>
  <p>This is my <code>doctrine.yaml</code> file :</p>
  <pre><code>parameters:
      # Adds a fallback DATABASE_URL if the env var is not set.
      # This allows you to run cache:warmup even if your
      # environment variables are not available yet.
      # You should not need to change this value.
      env(DATABASE_URL): ''
  
  doctrine:
      dbal:
          # configure these for your database server
          driver: 'pdo_mysql'
          server_version: '5.7'
          charset: utf8
          default_table_options:
              charset: utf8
              collate: utf8_unicode_ci
  
          url: '%env(resolve:DATABASE_URL)%'
      orm:
          auto_generate_proxy_classes: '%kernel.debug%'
          naming_strategy: doctrine.orm.naming_strategy.underscore
          auto_mapping: true
          mappings:
              App:
                  is_bundle: false
                  type: annotation
                  dir: '%kernel.project_dir%/src/Entity'
                  prefix: 'App\Entity'
                  alias: App
  </code></pre>
  <p>I've not edited the database url parameter because it is already defined in <code>.env</code>. Am I right ?</p>