Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 2.7:
  Added doc about Homestead's Symfony integration
  remove note about memory spool handling on CLI
  [Cookbook][Serializer] fix wording
  Document translation_domain setting for choice fields
  translation_domain doc fix
  choice_translation_domain doc fix
  Travis fix
  Update entity.rst
  • Loading branch information
xabbuh committed Feb 10, 2016
2 parents d1e3024 + ebe0724 commit c00626c
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 48 deletions.
2 changes: 1 addition & 1 deletion book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ URL) rather than the ``path()`` function (which generates a relative URL):
The host that's used when generating an absolute URL is automatically
detected using the current ``Request`` object. When generating absolute
URLs from outside the web context (for instance in a console command) this
doesn't work. See :doc:`/cookbook/console/sending_emails` to learn how to
doesn't work. See :doc:`/cookbook/console/request_context` to learn how to
solve this problem.

Summary
Expand Down
2 changes: 1 addition & 1 deletion cookbook/console/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Console
usage
style
command_in_controller
sending_emails
request_context
logging
commands_as_services
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.. index::
single: Console; Sending emails
single: Console; Generating URLs

How to Generate URLs and Send Emails from the Console
=====================================================
How to Generate URLs from the Console
=====================================

Unfortunately, the command line context does not know about your VirtualHost
or domain name. This means that if you generate absolute URLs within a
Expand Down Expand Up @@ -81,43 +80,3 @@ from the ``router`` service and override its settings::
// ... your code here
}
}

Using Memory Spooling
---------------------

.. versionadded:: 2.3
When using Symfony 2.3+ and SwiftmailerBundle 2.3.5+, the memory spool is now
handled automatically in the CLI and the code below is not necessary anymore.

Sending emails in a console command works the same way as described in the
:doc:`/cookbook/email/email` cookbook except if memory spooling is used.

When using memory spooling (see the :doc:`/cookbook/email/spool` cookbook for more
information), you must be aware that because of how Symfony handles console
commands, emails are not sent automatically. You must take care of flushing
the queue yourself. Use the following code to send emails inside your
console command::

$message = new \Swift_Message();

// ... prepare the message

$container = $this->getContainer();
$mailer = $container->get('mailer');

$mailer->send($message);

// now manually flush the queue
$spool = $mailer->getTransport()->getSpool();
$transport = $container->get('swiftmailer.transport.real');

$spool->flushQueue($transport);

Another option is to create an environment which is only used by console
commands and uses a different spooling method.

.. note::

Taking care of the spooling is only needed when memory spooling is used.
If you are using file spooling (or no spooling at all), there is no need
to flush the queue manually within the command.
3 changes: 2 additions & 1 deletion cookbook/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* :doc:`/cookbook/console/usage`
* :doc:`/cookbook/console/style`
* :doc:`/cookbook/console/command_in_controller`
* :doc:`/cookbook/console/sending_emails`
* :doc:`/cookbook/console/request_context`
* :doc:`/cookbook/console/logging`
* :doc:`/cookbook/console/commands_as_services`

Expand Down Expand Up @@ -265,3 +265,4 @@

* :doc:`/cookbook/workflow/new_project_git`
* :doc:`/cookbook/workflow/new_project_svn`
* :doc:`/cookbook/workflow/homestead`
3 changes: 2 additions & 1 deletion cookbook/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ Enabling the Metadata Cache
---------------------------

.. versionadded:: 2.7
Serializer was introduced in Symfony 2.7.
Serializer metadata and the ability to cache them were introduced in
Symfony 2.7.

Metadata used by the Serializer component such as groups can be cached to
enhance application performance. Any service implementing the ``Doctrine\Common\Cache\Cache``
Expand Down
76 changes: 76 additions & 0 deletions cookbook/workflow/homestead.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
.. index:: Vagrant, Homestead

Using Symfony with Homestead/Vagrant
====================================

In order to develop a Symfony application, you might want to use a virtual
development environment instead of the built-in server or WAMP/LAMP. Homestead_
is an easy-to-use Vagrant_ box to get a virtual environment up and running
quickly.

.. tip::

Due to the amount of filesystem operations in Symfony (e.g. updating cache
files and writing to log files), Symfony can slow down signifcantly. To
improve the speed, consider :ref:`overriding the cache and log directories <override-cache-dir>`
to a location outside the NFS share (for instance, by using
:phpfunction:`sys_get_temp_dir`). You can read `this blog post`_ for more
tips to speed up Symfony on Vagrant.

Install Vagrant and Homestead
-----------------------------

Before you can use Homestead, you need to install and configure Vagrant and
Homestead as explained in `the Homestead documentation`_.

Setting Up a Symfony Application
--------------------------------

Imagine you've installed your Symfony application in
``~/projects/symfony_demo`` on your local system. You first need Homestead to
sync your files in this project. Execute ``homestead edit`` to edit the
Homestead configuration and configure the ``~/projects`` directory:

.. code-block:: yaml
# ...
folders:
- map: ~/projects
to: /home/vagrant/projects
The ``projects/`` directory on your PC is now accessible at
``/home/vagrant/projects`` in the Homestead environment.

After you've done this, configure the Symfony application in the Homestead
configuration:

.. code-block:: yaml
# ...
sites:
- map: symfony-demo.dev
to: /home/vagrant/projects/symfony_demo/web
type: symfony
The ``type`` option tells Homestead to use the Symfony nginx configuration.

At last, edit the hosts file on your local machine to map ``symfony-demo.dev``
to ``192.168.10.10`` (which is the IP used by Homestead)::

# /etc/hosts (unix) or C:\Windows\System32\drivers\etc\hosts (Windows)
192.168.10.10 symfony-demo.dev

Now, navigate to ``http://symfony-demo.dev`` in your web browser and enjoy
developing your Symfony application!

.. seealso::

To learn more features of Homestead, including Blackfire Profiler
integration, automatic creation of MySQL databases and more, read the
`Daily Usage`_ section of the Homestead documentation.

.. _Homestead: http://laravel.com/docs/homestead
.. _Vagrant: https://www.vagrantup.com/
.. _the Homestead documentation: http://laravel.com/docs/homestead#installation-and-setup
.. _Daily Usage: http://laravel.com/docs/5.1/homestead#daily-usage
.. _this blog post: http://www.whitewashing.de/2013/08/19/speedup_symfony2_on_vagrant_boxes.html
1 change: 1 addition & 0 deletions cookbook/workflow/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Workflow

new_project_git
new_project_svn
homestead
1 change: 1 addition & 0 deletions redirection_map
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/book/stable_api /contributing/code/bc
/book/internals /reference/events
/cookbook/console/sending_emails /cookbook/console/request_context
/cookbook/deployment-tools /cookbook/deployment/tools
/cookbook/doctrine/migrations /bundles/DoctrineFixturesBundle/index
/cookbook/doctrine/doctrine_fixtures /bundles/DoctrineFixturesBundle/index
Expand Down
4 changes: 4 additions & 0 deletions reference/forms/types/choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
| | - `choice_loader`_ |
| | - `choice_label`_ |
| | - `choice_attr`_ |
| | - `choice_translation_domain`_ |
| | - `placeholder`_ |
| | - `expanded`_ |
| | - `multiple`_ |
Expand All @@ -41,6 +42,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
| | - `mapped`_ |
| | - `read_only`_ (deprecated as of 2.8) |
| | - `required`_ |
| | - `translation_domain`_ |
+-------------+------------------------------------------------------------------------------+
| Parent type | :doc:`FormType </reference/forms/types/form>` |
+-------------+------------------------------------------------------------------------------+
Expand Down Expand Up @@ -361,6 +363,8 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:

.. include:: /reference/forms/types/options/required.rst.inc

.. include:: /reference/forms/types/options/choice_type_translation_domain.rst.inc

Field Variables
---------------

Expand Down
4 changes: 3 additions & 1 deletion reference/forms/types/entity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ objects from the database.
| options | |
| | - `placeholder`_ |
| | - `choice_translation_domain`_ |
| | - `translation_domain`_ |
| | - `expanded`_ |
| | - `multiple`_ |
| | - `preferred_choices`_ |
Expand Down Expand Up @@ -195,7 +196,6 @@ em
If specified, this entity manager will be used to load the choices
instead of the ``default`` entity manager.


Overridden Options
------------------

Expand All @@ -217,6 +217,8 @@ These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`

.. include:: /reference/forms/types/options/choice_translation_domain.rst.inc

.. include:: /reference/forms/types/options/choice_type_translation_domain.rst.inc

.. include:: /reference/forms/types/options/expanded.rst.inc

.. include:: /reference/forms/types/options/multiple.rst.inc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
translation_domain
~~~~~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``messages``

In case `choice_translation_domain`_ is set to ``true`` or ``null``, this
configures the exact translation domain that will be used for any labels or
options that are rendered for this field

0 comments on commit c00626c

Please sign in to comment.