Skip to content

Commit 67919d9

Browse files
committed
Merge remote-tracking branch 'upstream/2.3' into cookbook-grammar-and-style-fixes
2 parents e1c0ec2 + cad4d3f commit 67919d9

File tree

6 files changed

+207
-2
lines changed

6 files changed

+207
-2
lines changed

components/console/helpers/dialoghelper.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,18 @@ Testing a Command which Expects Input
253253
If you want to write a unit test for a command which expects some kind of input
254254
from the command line, you need to overwrite the HelperSet used by the command::
255255

256+
use Symfony\Component\Console\Application;
256257
use Symfony\Component\Console\Helper\DialogHelper;
257258
use Symfony\Component\Console\Helper\HelperSet;
259+
use Symfony\Component\Console\Tester\CommandTester;
258260

259261
// ...
260262
public function testExecute()
261263
{
262264
// ...
265+
$application = new Application();
266+
$application->add(new MyCommand());
267+
$command = $application->find('my:command:name');
263268
$commandTester = new CommandTester($command);
264269

265270
$dialog = $command->getHelper('dialog');
@@ -285,3 +290,8 @@ By setting the input stream of the ``DialogHelper``, you imitate what the
285290
console would do internally with all user input through the cli. This way
286291
you can test any user interaction (even complex ones) by passing an appropriate
287292
input stream.
293+
294+
.. seealso::
295+
296+
You find more information about testing commands in the console component
297+
docs about :ref:`testing console commands <component-console-testing-commands>`.

components/console/introduction.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ declare a one-letter shortcut that you can call with a single dash like
297297
.. tip::
298298

299299
It is also possible to make an option *optionally* accept a value (so that
300-
``--yell`` or ``--yell=loud`` or ``--yell loud`` work). Options can also be configured to
300+
``--yell``, ``--yell=loud`` or ``--yell loud`` work). Options can also be configured to
301301
accept an array of values.
302302

303303
For example, add a new option to the command that can be used to specify
@@ -377,6 +377,8 @@ tools capable of helping you with different tasks:
377377
* :doc:`/components/console/helpers/progresshelper`: shows a progress bar
378378
* :doc:`/components/console/helpers/tablehelper`: displays tabular data as a table
379379

380+
.. _component-console-testing-commands:
381+
380382
Testing Commands
381383
----------------
382384

cookbook/deployment/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Deployment
77
tools
88
azure-website
99
heroku
10+
platformsh

cookbook/deployment/platformsh.rst

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
.. index::
2+
single: Deployment; Deploying to Platform.sh
3+
4+
Deploying to Platform.sh
5+
========================
6+
7+
This step-by-step cookbook describes how to deploy a Symfony web application to
8+
`Platform.sh`_. You can read more about using Symfony with Platform.sh on the
9+
official `Platform.sh documentation`_.
10+
11+
Deploy an Existing Site
12+
-----------------------
13+
14+
In this guide, it is assumed your codebase is already versioned with Git.
15+
16+
Get a Project on Platform.sh
17+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18+
19+
You need to subscribe to a `Platform.sh project`_. Choose the development plan
20+
and go through the checkout process. Once your project is ready, give it a name
21+
and choose: **Import an existing site**.
22+
23+
Prepare Your Application
24+
~~~~~~~~~~~~~~~~~~~~~~~~
25+
26+
To deploy your Symfony application on Platform.sh, you simply need to add a
27+
``.platform.app.yaml`` at the root of your Git repository which will tell
28+
Platform.sh how to deploy your application (read more about
29+
`Platform.sh configuration files`_).
30+
31+
.. code-block:: yaml
32+
33+
# .platform.app.yaml
34+
35+
# This file describes an application. You can have multiple applications
36+
# in the same project.
37+
38+
# The name of this app. Must be unique within a project.
39+
name: myphpproject
40+
41+
# The toolstack used to build the application.
42+
toolstack: "php:symfony"
43+
44+
# The relationships of the application with services or other applications.
45+
# The left-hand side is the name of the relationship as it will be exposed
46+
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
47+
# side is in the form `<service name>:<endpoint name>`.
48+
relationships:
49+
database: "mysql:mysql"
50+
51+
# The configuration of app when it is exposed to the web.
52+
web:
53+
# The public directory of the app, relative to its root.
54+
document_root: "/web"
55+
# The front-controller script to send non-static requests to.
56+
passthru: "/app.php"
57+
58+
# The size of the persistent disk of the application (in MB).
59+
disk: 2048
60+
61+
# The mounts that will be performed when the package is deployed.
62+
mounts:
63+
"/app/cache": "shared:files/cache"
64+
"/app/logs": "shared:files/logs"
65+
66+
# The hooks that will be performed when the package is deployed.
67+
hooks:
68+
build: |
69+
rm web/app_dev.php
70+
app/console --env=prod assetic:dump --no-debug
71+
deploy: |
72+
app/console --env=prod cache:clear
73+
74+
For best practices, you should also add a ``.platform`` folder at the root of
75+
your Git repository which contains the following files:
76+
77+
.. code-block:: yaml
78+
79+
# .platform/routes.yaml
80+
"http://{default}/":
81+
type: upstream
82+
upstream: "php:php"
83+
84+
.. code-block:: yaml
85+
86+
# .platform/services.yaml
87+
mysql:
88+
type: mysql
89+
disk: 2048
90+
91+
An example of these configurations can be found on `GitHub`_. The list of
92+
`available services <configure-services>`_ can be found on the Platform.sh documentation.
93+
94+
Configure Database Access
95+
~~~~~~~~~~~~~~~~~~~~~~~~~
96+
97+
Platform.sh overrides your database specific configuration via importing the
98+
following file::
99+
100+
// app/config/parameters_platform.php
101+
<?php
102+
$relationships = getenv("PLATFORM_RELATIONSHIPS");
103+
if (!$relationships) {
104+
return;
105+
}
106+
107+
$relationships = json_decode(base64_decode($relationships), true);
108+
109+
foreach ($relationships['database'] as $endpoint) {
110+
if (empty($endpoint['query']['is_master'])) {
111+
continue;
112+
}
113+
114+
$container->setParameter('database_driver', 'pdo_' . $endpoint['scheme']);
115+
$container->setParameter('database_host', $endpoint['host']);
116+
$container->setParameter('database_port', $endpoint['port']);
117+
$container->setParameter('database_name', $endpoint['path']);
118+
$container->setParameter('database_user', $endpoint['username']);
119+
$container->setParameter('database_password', $endpoint['password']);
120+
$container->setParameter('database_path', '');
121+
}
122+
123+
# Store session into /tmp.
124+
ini_set('session.save_path', '/tmp/sessions');
125+
126+
Make sure this file is listed in your *imports*:
127+
128+
.. code-block:: yaml
129+
130+
# app/config/config.yml
131+
imports:
132+
- { resource: parameters_platform.php }
133+
134+
Deploy your Application
135+
~~~~~~~~~~~~~~~~~~~~~~~
136+
137+
Now you need to add a remote to Platform.sh in your Git repository (copy the
138+
command that you see on the Platform.sh web UI):
139+
140+
.. code-block:: bash
141+
142+
$ git remote add platform [PROJECT-ID]@git.[CLUSTER].platform.sh:[PROJECT-ID].git
143+
144+
``PROJECT-ID``
145+
Unique identifier of your project. Something like ``kjh43kbobssae``
146+
``CLUSTER``
147+
Server location where your project is deplyed. It can be ``eu`` or ``us``
148+
149+
Commit the Platform.sh specific files created in the previous section:
150+
151+
.. code-block:: bash
152+
153+
$ git add .platform.app.yaml .platform/*
154+
$ git add app/config/config.yml app/config/parameters_platform.php
155+
$ git commit -m "Adding Platform.sh configuration files."
156+
157+
Push your code base to the newly added remote:
158+
159+
.. code-block:: bash
160+
161+
$ git push platform master
162+
163+
That's it! Your application is being deployed on Platform.sh and you'll soon be
164+
able to access it in your browser.
165+
166+
Every code change that you do from now on will be pushed to Git in order to
167+
redeploy your environment on Platform.sh.
168+
169+
More information about `migrating your database and files <migrate-existing-site>`_ can be found on the
170+
Platform.sh documentation.
171+
172+
Deploy a new Site
173+
-----------------
174+
175+
You can start a new `Platform.sh project`_. Choose the development plan and go
176+
through the checkout process.
177+
178+
Once your project is ready, give it a name and choose: **Create a new site**.
179+
Choose the *Symfony* stack and a starting point such as *Standard*.
180+
181+
That's it! Your Symfony application will be bootstrapped and deployed. You'll
182+
soon be able to see it in your browser.
183+
184+
.. _`Platform.sh`: https://platform.sh
185+
.. _`Platform.sh documentation`: https://docs.platform.sh/toolstacks/symfony/symfony-getting-started
186+
.. _`Platform.sh project`: https://marketplace.commerceguys.com/platform/buy-now
187+
.. _`Platform.sh configuration files`: https://docs.platform.sh/reference/configuration-files
188+
.. _`GitHub`: https://github.com/platformsh/platformsh-examples
189+
.. _`configure-services`: https://docs.platform.sh/reference/configuration-files/#configure-services
190+
.. _`migrate-existing-site`: https://docs.platform.sh/toolstacks/symfony/migrate-existing-site/

cookbook/form/form_customization.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ resource to use such a layout:
502502
# app/config/config.yml
503503
twig:
504504
form:
505-
resources: ['form_table_layout.html.twig']
505+
resources:
506+
- 'form_table_layout.html.twig'
506507
# ...
507508
508509
.. code-block:: xml

cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
* :doc:`/cookbook/deployment/tools`
5555
* :doc:`/cookbook/deployment/azure-website`
5656
* :doc:`/cookbook/deployment/heroku`
57+
* :doc:`/cookbook/deployment/platformsh`
5758

5859
* :doc:`/cookbook/doctrine/index`
5960

0 commit comments

Comments
 (0)