From 3a523e18c8d23cbe5ea38b897e738be3592bd220 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 28 Sep 2018 00:43:02 +0200 Subject: [PATCH 1/5] Added `charset` "query string" Couldn't find any reference for `charset` in `DATABASE_URL` anywhere, so I'm just adding it here... Is there a list of *all* possible query string parameters somewhere? --- doctrine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doctrine.rst b/doctrine.rst index 8506ddaf86b..f69d10401b0 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -42,7 +42,7 @@ The database connection information is stored as an environment variable called # .env # customize this line! - DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name" + DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?charset=utf8mb4&serverVersion=5.7" # to use sqlite: # DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db" From 2aa9ff7bbc7275b19f446f1636ba43b39449f727 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 28 Sep 2018 01:01:21 +0200 Subject: [PATCH 2/5] Update doctrine.rst * Added info about the slash in a "host" name like `/data/sockets/databases/postgresql` (took me hours to figure it out!) * Added info that urlencoded parameters in conjunction with ``resolve:`` leads to an error message. --- doctrine.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doctrine.rst b/doctrine.rst index f69d10401b0..13f04175dbe 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -49,10 +49,12 @@ The database connection information is stored as an environment variable called .. caution:: - If the username, password or database name contain any character considered - special in a URI (such as ``!``, ``@``, ``$``, ``#``), you must encode them. + If the username, password, host 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 - :phpfunction:`urlencode` function to encode them. + :phpfunction:`urlencode` function to encode them. In this case you need to remove + the ``resolve:`` prefix in ``config/packages/doctrine.yaml``: + ``url: '%env(resolve:DATABASE_URL)%'`` Now that your connection parameters are setup, Doctrine can create the ``db_name`` database for you: From 6d8ec6ab77d42061c52bdacd224fe100a99ca790 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 28 Sep 2018 01:06:49 +0200 Subject: [PATCH 3/5] Update configuration.rst Crossreference: https://github.com/symfony/symfony-docs/pull/10410/commits/2aa9ff7bbc7275b19f446f1636ba43b39449f727 --- configuration.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configuration.rst b/configuration.rst index 88e96cb92e5..ef41fe895cc 100644 --- a/configuration.rst +++ b/configuration.rst @@ -227,8 +227,9 @@ This is referenced inside ``config/packages/doctrine.yaml``: dbal: url: '%env(DATABASE_URL)%' - # the resolve: prefix will resolve parameters *inside* the env variable + # The `resolve:` prefix will resolve parameters *inside* the env variable: # url: '%env(resolve:DATABASE_URL)%' + # This will not work if you have urlencoded values in your `DATABASE_URL`. For more details about environment variables, see :ref:`config-env-vars`. From eb93d15e1d6eaa892d690a6e2125e1829ed50705 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 8 Oct 2018 10:11:54 +0200 Subject: [PATCH 4/5] Reword --- configuration.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configuration.rst b/configuration.rst index ef41fe895cc..661b2a972e0 100644 --- a/configuration.rst +++ b/configuration.rst @@ -227,9 +227,8 @@ This is referenced inside ``config/packages/doctrine.yaml``: dbal: url: '%env(DATABASE_URL)%' - # The `resolve:` prefix will resolve parameters *inside* the env variable: + # The `resolve:` prefix replaces container params by their values inside the env variable: # url: '%env(resolve:DATABASE_URL)%' - # This will not work if you have urlencoded values in your `DATABASE_URL`. For more details about environment variables, see :ref:`config-env-vars`. From 5f9ae66b718b651e76678b6466eb7b896c9db74b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 8 Oct 2018 10:13:57 +0200 Subject: [PATCH 5/5] Reword --- doctrine.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doctrine.rst b/doctrine.rst index 13f04175dbe..493be738bf6 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -42,7 +42,7 @@ The database connection information is stored as an environment variable called # .env # customize this line! - DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?charset=utf8mb4&serverVersion=5.7" + DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name" # to use sqlite: # DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db" @@ -53,7 +53,7 @@ The database connection information is stored as an environment variable called special in a URI (such as ``!``, ``@``, ``$``, ``#``, ``/``), you must encode them. See `RFC 3986`_ for the full list of reserved characters or use the :phpfunction:`urlencode` function to encode them. In this case you need to remove - the ``resolve:`` prefix in ``config/packages/doctrine.yaml``: + the ``resolve:`` prefix in ``config/packages/doctrine.yaml`` to avoid errors: ``url: '%env(resolve:DATABASE_URL)%'`` Now that your connection parameters are setup, Doctrine can create the ``db_name``