diff --git a/cookbook/symfony1.rst b/cookbook/symfony1.rst index 3ceb8d69deb..dc26c7c12ff 100644 --- a/cookbook/symfony1.rst +++ b/cookbook/symfony1.rst @@ -266,11 +266,35 @@ 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 - _hello: - resource: "@AcmeDemoBundle/Resources/config/routing.yml" + + + + .. 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 @@ -278,11 +302,25 @@ 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 + + + + + + + .. 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. @@ -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: foo.bar@example.com + + .. code-block:: xml + + + foo.bar@example.com + + + .. code-block:: php - parameters: - email.from_address: foo.bar@example.com + $container->setParameter('email.from_address', 'foo.bar@example.com'); You can now access this from a controller, for example::