Skip to content

Commit ebe0724

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: Added doc about Homestead's Symfony integration remove note about memory spool handling on CLI
2 parents bef2b66 + 66f035b commit ebe0724

File tree

7 files changed

+84
-46
lines changed

7 files changed

+84
-46
lines changed

book/routing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ to ``generate()``:
15901590
The host that's used when generating an absolute URL is automatically
15911591
detected using the current ``Request`` object. When generating absolute
15921592
URLs from outside the web context (for instance in a console command) this
1593-
doesn't work. See :doc:`/cookbook/console/sending_emails` to learn how to
1593+
doesn't work. See :doc:`/cookbook/console/request_context` to learn how to
15941594
solve this problem.
15951595

15961596
Summary

cookbook/console/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Console
88
usage
99
style
1010
command_in_controller
11-
sending_emails
11+
request_context
1212
logging
1313
commands_as_services

cookbook/console/sending_emails.rst renamed to cookbook/console/request_context.rst

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
.. index::
2-
single: Console; Sending emails
32
single: Console; Generating URLs
43

5-
How to Generate URLs and Send Emails from the Console
6-
=====================================================
4+
How to Generate URLs from the Console
5+
=====================================
76

87
Unfortunately, the command line context does not know about your VirtualHost
98
or domain name. This means that if you generate absolute URLs within a
@@ -81,43 +80,3 @@ from the ``router`` service and override its settings::
8180
// ... your code here
8281
}
8382
}
84-
85-
Using Memory Spooling
86-
---------------------
87-
88-
.. versionadded:: 2.3
89-
When using Symfony 2.3+ and SwiftmailerBundle 2.3.5+, the memory spool is now
90-
handled automatically in the CLI and the code below is not necessary anymore.
91-
92-
Sending emails in a console command works the same way as described in the
93-
:doc:`/cookbook/email/email` cookbook except if memory spooling is used.
94-
95-
When using memory spooling (see the :doc:`/cookbook/email/spool` cookbook for more
96-
information), you must be aware that because of how Symfony handles console
97-
commands, emails are not sent automatically. You must take care of flushing
98-
the queue yourself. Use the following code to send emails inside your
99-
console command::
100-
101-
$message = new \Swift_Message();
102-
103-
// ... prepare the message
104-
105-
$container = $this->getContainer();
106-
$mailer = $container->get('mailer');
107-
108-
$mailer->send($message);
109-
110-
// now manually flush the queue
111-
$spool = $mailer->getTransport()->getSpool();
112-
$transport = $container->get('swiftmailer.transport.real');
113-
114-
$spool->flushQueue($transport);
115-
116-
Another option is to create an environment which is only used by console
117-
commands and uses a different spooling method.
118-
119-
.. note::
120-
121-
Taking care of the spooling is only needed when memory spooling is used.
122-
If you are using file spooling (or no spooling at all), there is no need
123-
to flush the queue manually within the command.

cookbook/map.rst.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* :doc:`/cookbook/console/usage`
4747
* :doc:`/cookbook/console/style`
4848
* :doc:`/cookbook/console/command_in_controller`
49-
* :doc:`/cookbook/console/sending_emails`
49+
* :doc:`/cookbook/console/request_context`
5050
* :doc:`/cookbook/console/logging`
5151
* :doc:`/cookbook/console/commands_as_services`
5252

@@ -260,3 +260,4 @@
260260

261261
* :doc:`/cookbook/workflow/new_project_git`
262262
* :doc:`/cookbook/workflow/new_project_svn`
263+
* :doc:`/cookbook/workflow/homestead`

cookbook/workflow/homestead.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
.. index:: Vagrant, Homestead
2+
3+
Using Symfony with Homestead/Vagrant
4+
====================================
5+
6+
In order to develop a Symfony application, you might want to use a virtual
7+
development environment instead of the built-in server or WAMP/LAMP. Homestead_
8+
is an easy-to-use Vagrant_ box to get a virtual environment up and running
9+
quickly.
10+
11+
.. tip::
12+
13+
Due to the amount of filesystem operations in Symfony (e.g. updating cache
14+
files and writing to log files), Symfony can slow down signifcantly. To
15+
improve the speed, consider :ref:`overriding the cache and log directories <override-cache-dir>`
16+
to a location outside the NFS share (for instance, by using
17+
:phpfunction:`sys_get_temp_dir`). You can read `this blog post`_ for more
18+
tips to speed up Symfony on Vagrant.
19+
20+
Install Vagrant and Homestead
21+
-----------------------------
22+
23+
Before you can use Homestead, you need to install and configure Vagrant and
24+
Homestead as explained in `the Homestead documentation`_.
25+
26+
Setting Up a Symfony Application
27+
--------------------------------
28+
29+
Imagine you've installed your Symfony application in
30+
``~/projects/symfony_demo`` on your local system. You first need Homestead to
31+
sync your files in this project. Execute ``homestead edit`` to edit the
32+
Homestead configuration and configure the ``~/projects`` directory:
33+
34+
.. code-block:: yaml
35+
36+
# ...
37+
folders:
38+
- map: ~/projects
39+
to: /home/vagrant/projects
40+
41+
The ``projects/`` directory on your PC is now accessible at
42+
``/home/vagrant/projects`` in the Homestead environment.
43+
44+
After you've done this, configure the Symfony application in the Homestead
45+
configuration:
46+
47+
.. code-block:: yaml
48+
49+
# ...
50+
sites:
51+
- map: symfony-demo.dev
52+
to: /home/vagrant/projects/symfony_demo/web
53+
type: symfony
54+
55+
The ``type`` option tells Homestead to use the Symfony nginx configuration.
56+
57+
At last, edit the hosts file on your local machine to map ``symfony-demo.dev``
58+
to ``192.168.10.10`` (which is the IP used by Homestead)::
59+
60+
# /etc/hosts (unix) or C:\Windows\System32\drivers\etc\hosts (Windows)
61+
192.168.10.10 symfony-demo.dev
62+
63+
Now, navigate to ``http://symfony-demo.dev`` in your web browser and enjoy
64+
developing your Symfony application!
65+
66+
.. seealso::
67+
68+
To learn more features of Homestead, including Blackfire Profiler
69+
integration, automatic creation of MySQL databases and more, read the
70+
`Daily Usage`_ section of the Homestead documentation.
71+
72+
.. _Homestead: http://laravel.com/docs/homestead
73+
.. _Vagrant: https://www.vagrantup.com/
74+
.. _the Homestead documentation: http://laravel.com/docs/homestead#installation-and-setup
75+
.. _Daily Usage: http://laravel.com/docs/5.1/homestead#daily-usage
76+
.. _this blog post: http://www.whitewashing.de/2013/08/19/speedup_symfony2_on_vagrant_boxes.html

cookbook/workflow/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Workflow
66

77
new_project_git
88
new_project_svn
9+
homestead

redirection_map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/book/stable_api /contributing/code/bc
22
/book/internals /reference/events
3+
/cookbook/console/sending_emails /cookbook/console/request_context
34
/cookbook/deployment-tools /cookbook/deployment/tools
45
/cookbook/doctrine/migrations /bundles/DoctrineFixturesBundle/index
56
/cookbook/doctrine/doctrine_fixtures /bundles/DoctrineFixturesBundle/index

0 commit comments

Comments
 (0)