Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cookbook/symfony1] Added missing formats #6

Merged
merged 1 commit into from
Feb 18, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 61 additions & 11 deletions cookbook/symfony1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,23 +266,61 @@ configuration inside a bundle must be included manually. For example, to
include a routing resource from a bundle called ``AcmeDemoBundle``, you can
do the following:

.. code-block:: yaml
.. configuration-block::

.. code-block:: yaml

# app/config/routing.yml
_hello:
resource: "@AcmeDemoBundle/Resources/config/routing.yml"

.. code-block:: xml

<!-- app/config/routing.yml -->
<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

# app/config/routing.yml
_hello:
resource: "@AcmeDemoBundle/Resources/config/routing.yml"
<import resource="@AcmeDemoBundle/Resources/config/routing.xml" />
</routes>

.. code-block:: php

// app/config/routing.php
use Symfony\Component\Routing\RouteCollection;

$collection = new RouteCollection();
$collection->addCollection($loader->import("@AcmeHelloBundle/Resources/config/routing.php"));

return $collection;

This will load the routes found in the ``Resources/config/routing.yml`` file
of the ``AcmeDemoBundle``. The special ``@AcmeDemoBundle`` is a shortcut syntax
that, internally, resolves to the full path to that bundle.

You can use this same strategy to bring in configuration from a bundle:

.. code-block:: yaml
.. configuration-block::

# app/config/config.yml
imports:
- { resource: "@AcmeDemoBundle/Resources/config/config.yml" }
.. code-block:: yaml

# app/config/config.yml
imports:
- { resource: "@AcmeDemoBundle/Resources/config/config.yml" }

.. code-block:: xml

<!-- app/config/config.xml -->
<imports>
<import resource="@AcmeDemoBundle/Resources/config/config.xml" />
</imports>

.. code-block:: php

// app/config/config.php
$this->import('@AcmeDemoBundle/Resources/config/config.php')

In Symfony2, configuration is a bit like ``app.yml`` in symfony1, except much
more systematic. With ``app.yml``, you could simply create any keys you wanted.
Expand All @@ -299,10 +337,22 @@ used them in your application:
In Symfony2, you can also create arbitrary entries under the ``parameters``
key of your configuration:

.. code-block:: yaml
.. configuration-block::

.. code-block:: yaml

parameters:
email.from_address: [email protected]

.. code-block:: xml

<parameters>
<parameter key="email.from_address">[email protected]</parameter>
</parameters>

.. code-block:: php

parameters:
email.from_address: [email protected]
$container->setParameter('email.from_address', '[email protected]');

You can now access this from a controller, for example::

Expand Down