From 3bd0872bf6637464f52a9d7fc844504ee5804d8c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 1 Apr 2019 13:12:06 +0200 Subject: [PATCH 1/5] Documented the use of Docker with the Symfony server --- setup/symfony_server.rst | 110 +++++++++++++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 11 deletions(-) diff --git a/setup/symfony_server.rst b/setup/symfony_server.rst index 5f991b827fa..0f196353697 100644 --- a/setup/symfony_server.rst +++ b/setup/symfony_server.rst @@ -244,6 +244,104 @@ server provides a ``run`` command to wrap them as follows: # stop the web server (and all the associated commands) when you are finished $ symfony server:stop +Docker Integration +------------------ + +The local Symfony server provides full `Docker`_ integration for projects that +use it. First, make sure to expose the container ports: + +.. code-block:: yaml + + # docker-compose.override.yaml + services: + database: + ports: + - "3600" + + redis: + ports: + - "6379" + + # ... + +Then, check your service names and update them if needed (Symfony creates +environment variables following the name of the services so they can be +autoconfigured): + +.. code-block:: yaml + + # docker-compose.yaml + services: + # DATABASE_URL + database: ... + # MONGODB_DATABASE, MONGODB_SERVER + mongodb: ... + # REDIS_URL + redis: ... + # ELASTISEARCH_HOST, ELASTICSEARCH_PORT + elasticsearch: ... + # RABBITMQ_DSN + rabbitmq: ... + +If you can't or don't want to update the service names, you must update the +Symfony application configuration to use the new environment variables. For +example, if you want to keep a service called ``mysql`` instead of renaming it +to ``database``, the env var will be called ``MYSQL_URL`` instead of +``DATABASE_URL``, so you must update the configuration as follows: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/doctrine.yaml + doctrine: + dbal: + url: '%env(MYSQL_URL)%' + # ... + + .. code-block:: xml + + + + + + + + + + + + .. code-block:: php + + // config/packages/doctrine.php + $container->loadFromExtension('doctrine', [ + 'dbal' => [ + 'url' => '%env(MYSQL_URL)%', + ] + ]); + +Now you can start the local Symfony server with ``symfony server:start`` and +Symfony will also start your containers. + +SymfonyCloud Integration +------------------------ + +The local Symfony server provides full, but optional, integration with +`SymfonyCloud`_, a service optimized to run your Symfony applications on the +cloud. It provides features such as creating environments, backups/snapshots, +and even access to a copy of the production data from your local machine to help +debug any issues. + +`Read SymfonyCloud technical docs`_. + Bonus Features -------------- @@ -282,18 +380,8 @@ commands from the Symfony server: # creates a new project based on the Symfony Demo application $ symfony new --demo my_project_name -SymfonyCloud Integration ------------------------- - -The local Symfony server provides full, but optional, integration with -`SymfonyCloud`_, a service optimized to run your Symfony applications on the -cloud. It provides features such as creating environments, backups/snapshots, -and even access to a copy of the production data from your local machine to help -debug any issues. - -`Read SymfonyCloud technical docs`_. - .. _`symfony.com/download`: https://symfony.com/download .. _`different ways of installing Symfony`: https://symfony.com/download +.. _`Docker`: https://en.wikipedia.org/wiki/Docker_(software) .. _`SymfonyCloud`: https://symfony.com/cloud/ .. _`Read SymfonyCloud technical docs`: https://symfony.com/doc/master/cloud/intro.html From 11495b8c4f92104875ba1f6d6e9d2e19d8f41ae4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 1 Apr 2019 15:06:08 +0200 Subject: [PATCH 2/5] Fixes --- setup/symfony_server.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup/symfony_server.rst b/setup/symfony_server.rst index 0f196353697..76b699af03b 100644 --- a/setup/symfony_server.rst +++ b/setup/symfony_server.rst @@ -328,8 +328,9 @@ to ``database``, the env var will be called ``MYSQL_URL`` instead of ] ]); -Now you can start the local Symfony server with ``symfony server:start`` and -Symfony will also start your containers. +Now you can start the containers and all their services will be exposed. Browse +any page of your application and check the "Symfony Server" section in the web +debug toolbar. You'll see that "Docker Compose" is "Up". SymfonyCloud Integration ------------------------ From f283a1ed22acf784f4e97364c826fb33d2c097d8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 1 Apr 2019 16:36:20 +0200 Subject: [PATCH 3/5] - --- setup/symfony_server.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/symfony_server.rst b/setup/symfony_server.rst index 76b699af03b..08f3ef2ad6f 100644 --- a/setup/symfony_server.rst +++ b/setup/symfony_server.rst @@ -325,7 +325,7 @@ to ``database``, the env var will be called ``MYSQL_URL`` instead of $container->loadFromExtension('doctrine', [ 'dbal' => [ 'url' => '%env(MYSQL_URL)%', - ] + ], ]); Now you can start the containers and all their services will be exposed. Browse From 7237d00b0756efbb8441cae49c4e98ee64cba1ba Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 3 Apr 2019 10:33:17 +0200 Subject: [PATCH 4/5] Simpler remapping of env vars --- setup/symfony_server.rst | 55 ++++++++-------------------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/setup/symfony_server.rst b/setup/symfony_server.rst index 08f3ef2ad6f..8f996d49829 100644 --- a/setup/symfony_server.rst +++ b/setup/symfony_server.rst @@ -283,50 +283,17 @@ autoconfigured): # RABBITMQ_DSN rabbitmq: ... -If you can't or don't want to update the service names, you must update the -Symfony application configuration to use the new environment variables. For -example, if you want to keep a service called ``mysql`` instead of renaming it -to ``database``, the env var will be called ``MYSQL_URL`` instead of -``DATABASE_URL``, so you must update the configuration as follows: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/doctrine.yaml - doctrine: - dbal: - url: '%env(MYSQL_URL)%' - # ... - - .. code-block:: xml - - - - - - - - - - - - .. code-block:: php - - // config/packages/doctrine.php - $container->loadFromExtension('doctrine', [ - 'dbal' => [ - 'url' => '%env(MYSQL_URL)%', - ], - ]); +If you can't or don't want to update the service names, you must remap the env +vars so Symfony can find them. For example, if you want to keep a service called +``mysql`` instead of renaming it to ``database``, the env var will be called +``MYSQL_URL`` instead of the ``DATABASE_URL`` env var used in the Symfony +application, so you add the following to the ``.env.local`` file: + +.. code-block:: bash + + # .env.local + MYSQL_URL=${DATABASE_URL} + # ... Now you can start the containers and all their services will be exposed. Browse any page of your application and check the "Symfony Server" section in the web From 01ec0438106b6158262d01d2869f49332221fb29 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 4 Apr 2019 15:10:44 +0200 Subject: [PATCH 5/5] Fixed the MySQL port number --- setup/symfony_server.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/symfony_server.rst b/setup/symfony_server.rst index 8f996d49829..2f13761fe3d 100644 --- a/setup/symfony_server.rst +++ b/setup/symfony_server.rst @@ -256,7 +256,7 @@ use it. First, make sure to expose the container ports: services: database: ports: - - "3600" + - "3306" redis: ports: