@@ -41,7 +41,7 @@ do this, create a new template file that will store the new markup:
.. code-block:: html+php
-
+
label($form, $label) ?>
errors($form) ?>
@@ -57,7 +57,7 @@ renders the form:
.. code-block:: html+twig
- {# app/Resources/views/default/new.html.twig #}
+ {# templates/default/new.html.twig #}
{% form_theme form 'form/fields.html.twig' %}
{# or if you want to use multiple themes #}
@@ -67,7 +67,7 @@ renders the form:
.. code-block:: html+php
-
+
setTheme($form, array('form')) ?>
@@ -272,7 +272,7 @@ to define form output.
PHP
...
-To automatically include the customized templates from the ``app/Resources/views/form``
+To automatically include the customized templates from the ``templates/form``
directory created earlier in *all* templates, modify your application configuration
file:
@@ -323,7 +323,7 @@ file:
// ...
));
-Any fragments inside the ``app/Resources/views/form`` directory are now used
+Any fragments inside the ``templates/form`` directory are now used
globally to define form output.
.. _`form_div_layout.html.twig`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
diff --git a/form/inherit_data_option.rst b/form/inherit_data_option.rst
index e633c43ea77..3a3cfa5b010 100644
--- a/form/inherit_data_option.rst
+++ b/form/inherit_data_option.rst
@@ -8,8 +8,8 @@ The ``inherit_data`` form field option can be very useful when you have some
duplicated fields in different entities. For example, imagine you have two
entities, a ``Company`` and a ``Customer``::
- // src/AppBundle/Entity/Company.php
- namespace AppBundle\Entity;
+ // src/Entity/Company.php
+ namespace App\Entity;
class Company
{
@@ -24,8 +24,8 @@ entities, a ``Company`` and a ``Customer``::
.. code-block:: php
- // src/AppBundle/Entity/Customer.php
- namespace AppBundle\Entity;
+ // src/Entity/Customer.php
+ namespace App\Entity;
class Customer
{
@@ -43,8 +43,8 @@ As you can see, each entity shares a few of the same fields: ``address``,
Start with building two forms for these entities, ``CompanyType`` and ``CustomerType``::
- // src/AppBundle/Form/Type/CompanyType.php
- namespace AppBundle\Form\Type;
+ // src/Form/Type/CompanyType.php
+ namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -62,8 +62,8 @@ Start with building two forms for these entities, ``CompanyType`` and ``Customer
.. code-block:: php
- // src/AppBundle/Form/Type/CustomerType.php
- namespace AppBundle\Form\Type;
+ // src/Form/Type/CustomerType.php
+ namespace App\Form\Type;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\AbstractType;
@@ -83,8 +83,8 @@ Instead of including the duplicated fields ``address``, ``zipcode``, ``city``
and ``country`` in both of these forms, create a third form called ``LocationType``
for that::
- // src/AppBundle/Form/Type/LocationType.php
- namespace AppBundle\Form\Type;
+ // src/Form/Type/LocationType.php
+ namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -125,8 +125,8 @@ access the properties of the ``Customer`` instance instead. Easy, eh?
Finally, make this work by adding the location form to your two original forms::
- // src/AppBundle/Form/Type/CompanyType.php
- use AppBundle\Entity\Company;
+ // src/Form/Type/CompanyType.php
+ use App\Entity\Company;
// ...
public function buildForm(FormBuilderInterface $builder, array $options)
@@ -140,8 +140,8 @@ Finally, make this work by adding the location form to your two original forms::
.. code-block:: php
- // src/AppBundle/Form/Type/CustomerType.php
- use AppBundle\Entity\Customer;
+ // src/Form/Type/CustomerType.php
+ use App\Entity\Customer;
// ...
public function buildForm(FormBuilderInterface $builder, array $options)
diff --git a/form/rendering.rst b/form/rendering.rst
index 65fa4ecf0bb..5483a33748a 100644
--- a/form/rendering.rst
+++ b/form/rendering.rst
@@ -11,7 +11,7 @@ of code. Of course, you'll usually need much more flexibility when rendering:
.. code-block:: html+twig
- {# app/Resources/views/default/new.html.twig #}
+ {# templates/default/new.html.twig #}
{{ form_start(form) }}
{{ form_errors(form) }}
@@ -21,7 +21,7 @@ of code. Of course, you'll usually need much more flexibility when rendering:
.. code-block:: html+php
-
+
start($form) ?>
errors($form) ?>
diff --git a/form/type_guesser.rst b/form/type_guesser.rst
index 7fdfbf04f86..4ec50fc9712 100644
--- a/form/type_guesser.rst
+++ b/form/type_guesser.rst
@@ -38,8 +38,8 @@ This interface requires four methods:
Start by creating the class and these methods. Next, you'll learn how to fill each in::
- // src/AppBundle/Form/TypeGuesser/PHPDocTypeGuesser.php
- namespace AppBundle\Form\TypeGuesser;
+ // src/Form/TypeGuesser/PHPDocTypeGuesser.php
+ namespace App\Form\TypeGuesser;
use Symfony\Component\Form\FormTypeGuesserInterface;
@@ -84,7 +84,7 @@ The ``TypeGuess`` constructor requires three options:
With this knowledge, you can easily implement the ``guessType()`` method of the
``PHPDocTypeGuesser``::
- namespace AppBundle\Form\TypeGuesser;
+ namespace App\Form\TypeGuesser;
use Symfony\Component\Form\Guess\Guess;
use Symfony\Component\Form\Guess\TypeGuess;
@@ -184,16 +184,16 @@ and tag it with ``form.type_guesser``:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
- AppBundle\Form\TypeGuesser\PHPDocTypeGuesser:
+ App\Form\TypeGuesser\PHPDocTypeGuesser:
tags: [form.type_guesser]
.. code-block:: xml
-
+
-
+
@@ -209,8 +209,8 @@ and tag it with ``form.type_guesser``:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Form\TypeGuesser\PHPDocTypeGuesser;
+ // config/services.php
+ use App\Form\TypeGuesser\PHPDocTypeGuesser;
$container->register(PHPDocTypeGuesser::class)
->addTag('form.type_guesser')
diff --git a/form/unit_testing.rst b/form/unit_testing.rst
index 6ee3ffe0946..b869eea2c26 100644
--- a/form/unit_testing.rst
+++ b/form/unit_testing.rst
@@ -31,11 +31,11 @@ The Basics
The simplest ``TypeTestCase`` implementation looks like the following::
- // tests/AppBundle/Form/Type/TestedTypeTest.php
- namespace Tests\AppBundle\Form\Type;
+ // tests/Form/Type/TestedTypeTest.php
+ namespace App\Tests\Form\Type;
- use AppBundle\Form\Type\TestedType;
- use AppBundle\Model\TestObject;
+ use App\Form\Type\TestedType;
+ use App\Model\TestObject;
use Symfony\Component\Form\Test\TypeTestCase;
class TestedTypeTest extends TypeTestCase
@@ -114,10 +114,10 @@ To solve this, you have to mock the injected dependencies, instantiate your own
form type and use the :class:`Symfony\\Component\\Form\\PreloadedExtension` to
make sure the ``FormRegistry`` uses the created instance::
- // tests/AppBundle/Form/Type/TestedTypeTests.php
- namespace Tests\AppBundle\Form\Type;
+ // tests/Form/Type/TestedTypeTests.php
+ namespace App\Tests\Form\Type;
- use AppBundle\Form\Type\TestedType;
+ use App\Form\Type\TestedType;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Form\PreloadedExtension;
use Symfony\Component\Form\Test\TypeTestCase;
@@ -168,11 +168,11 @@ will be raised if you try to test a class that depends on other extensions.
The :method:`Symfony\\Component\\Form\\Test\\TypeTestCase::getExtensions` method
allows you to return a list of extensions to register::
- // tests/AppBundle/Form/Type/TestedTypeTests.php
- namespace Tests\AppBundle\Form\Type;
+ // tests/Form/Type/TestedTypeTests.php
+ namespace App\Tests\Form\Type;
// ...
- use AppBundle\Form\Type\TestedType;
+ use App\Form\Type\TestedType;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Form;
use Symfony\Component\Validator\ConstraintViolationList;
@@ -219,10 +219,10 @@ Testing against Different Sets of Data
If you are not familiar yet with PHPUnit's `data providers`_, this might be
a good opportunity to use them::
- // tests/AppBundle/Form/Type/TestedTypeTests.php
- namespace Tests\AppBundle\Form\Type;
+ // tests/Form/Type/TestedTypeTests.php
+ namespace App\Tests\Form\Type;
- use AppBundle\Form\Type\TestedType;
+ use App\Form\Type\TestedType;
use Symfony\Component\Form\Test\TypeTestCase;
class TestedTypeTest extends TypeTestCase
diff --git a/form/use_empty_data.rst b/form/use_empty_data.rst
index 7d0597bf0be..482983ecdb1 100644
--- a/form/use_empty_data.rst
+++ b/form/use_empty_data.rst
@@ -43,11 +43,11 @@ One reason you might use this option is if you want to use a constructor
that takes arguments. Remember, the default ``data_class`` option calls
that constructor with no arguments::
- // src/AppBundle/Form/Type/BlogType.php
+ // src/Form/Type/BlogType.php
// ...
use Symfony\Component\Form\AbstractType;
- use AppBundle\Entity\Blog;
+ use App\Entity\Blog;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BlogType extends AbstractType
diff --git a/form/validation_group_service_resolver.rst b/form/validation_group_service_resolver.rst
index 79d0791d1eb..b4c9fe5c1cf 100644
--- a/form/validation_group_service_resolver.rst
+++ b/form/validation_group_service_resolver.rst
@@ -8,8 +8,8 @@ parameter.
.. code-block:: php
- // src/AppBundle/Validation/ValidationGroupResolver.php
- namespace AppBundle\Validation;
+ // src/Validation/ValidationGroupResolver.php
+ namespace App\Validation;
use Symfony\Component\Form\FormInterface;
@@ -43,10 +43,10 @@ Then in your form, inject the resolver and set it as the ``validation_groups``.
.. code-block:: php
- // src/AppBundle/Form/MyClassType.php;
- namespace AppBundle\Form;
+ // src/Form/MyClassType.php;
+ namespace App\Form;
- use AppBundle\Validator\ValidationGroupResolver;
+ use App\Validator\ValidationGroupResolver;
use Symfony\Component\Form\AbstractType
use Symfony\Component\OptionsResolver\OptionsResolver;
diff --git a/forms.rst b/forms.rst
index b6e57a28349..82a50ae0f60 100644
--- a/forms.rst
+++ b/forms.rst
@@ -27,8 +27,8 @@ display "tasks". Because your users will need to edit and create tasks, you're
going to need to build a form. But before you begin, first focus on the generic
``Task`` class that represents and stores the data for a single task::
- // src/AppBundle/Entity/Task.php
- namespace AppBundle\Entity;
+ // src/Entity/Task.php
+ namespace App\Entity;
class Task
{
@@ -74,10 +74,10 @@ render the actual HTML form. In Symfony, this is done by building a form
object and then rendering it in a template. For now, this can all be done
from inside a controller::
- // src/AppBundle/Controller/DefaultController.php
- namespace AppBundle\Controller;
+ // src/Controller/DefaultController.php
+ namespace App\Controller;
- use AppBundle\Entity\Task;
+ use App\Entity\Task;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -144,14 +144,14 @@ helper functions:
.. code-block:: html+twig
- {# app/Resources/views/default/new.html.twig #}
+ {# templates/default/new.html.twig #}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
.. code-block:: html+php
-
+
start($form) ?>
widget($form) ?>
end($form) ?>
@@ -317,8 +317,8 @@ object.
.. code-block:: php-annotations
- // src/AppBundle/Entity/Task.php
- namespace AppBundle\Entity;
+ // src/Entity/Task.php
+ namespace App\Entity;
use Symfony\Component\Validator\Constraints as Assert;
@@ -338,8 +338,8 @@ object.
.. code-block:: yaml
- # src/AppBundle/Resources/config/validation.yml
- AppBundle\Entity\Task:
+ # src/Resources/config/validation.yml
+ App\Entity\Task:
properties:
task:
- NotBlank: ~
@@ -349,14 +349,14 @@ object.
.. code-block:: xml
-
+
-
+
@@ -369,7 +369,7 @@ object.
.. code-block:: php
- // src/AppBundle/Entity/Task.php
+ // src/Entity/Task.php
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Type;
@@ -418,12 +418,12 @@ Validation is a very powerful feature of Symfony and has its own
.. code-block:: html+twig
- {# app/Resources/views/default/new.html.twig #}
+ {# templates/default/new.html.twig #}
{{ form(form, {'attr': {'novalidate': 'novalidate'}}) }}
.. code-block:: html+php
-
+
form($form, array(
'attr' => array('novalidate' => 'novalidate'),
)) ?>
@@ -590,8 +590,8 @@ However, a better practice is to build the form in a separate, standalone PHP
class, which can then be reused anywhere in your application. Create a new class
that will house the logic for building the task form::
- // src/AppBundle/Form/TaskType.php
- namespace AppBundle\Form;
+ // src/Form/TaskType.php
+ namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -612,8 +612,8 @@ that will house the logic for building the task form::
This new class contains all the directions needed to create the task form. It can
be used to quickly build a form object in the controller::
- // src/AppBundle/Controller/DefaultController.php
- use AppBundle\Form\TaskType;
+ // src/Controller/DefaultController.php
+ use App\Form\TaskType;
public function newAction()
{
@@ -639,8 +639,8 @@ the choice is ultimately up to you.
good idea to explicitly specify the ``data_class`` option by adding the
following to your form type class::
- // src/AppBundle/Form/TaskType.php
- use AppBundle\Entity\Task;
+ // src/Form/TaskType.php
+ use App\Entity\Task;
use Symfony\Component\OptionsResolver\OptionsResolver;
// ...
diff --git a/frontend.rst b/frontend.rst
index c971f5a67bd..c4172e3b3b9 100644
--- a/frontend.rst
+++ b/frontend.rst
@@ -3,7 +3,7 @@ Managing CSS and JavaScript
Symfony ships with a pure-JavaScript library - called Webpack Encore - that makes
working with CSS and JavaScript a joy. You can use it, use something else, or just
-create static CSS and JS files in your ``web/`` directory and include them in your
+create static CSS and JS files in your ``public/`` directory and include them in your
templates.
.. _frontend-webpack-encore:
diff --git a/frontend/custom_version_strategy.rst b/frontend/custom_version_strategy.rst
index 1dcd2754667..7cce1bb2144 100644
--- a/frontend/custom_version_strategy.rst
+++ b/frontend/custom_version_strategy.rst
@@ -45,8 +45,8 @@ In this example, the constructor of the class takes as arguments the path to
the manifest file generated by `gulp-buster`_ and the format of the generated
version string::
- // src/AppBundle/Asset/VersionStrategy/GulpBusterVersionStrategy.php
- namespace AppBundle\Asset\VersionStrategy;
+ // src/Asset/VersionStrategy/GulpBusterVersionStrategy.php
+ namespace App\Asset\VersionStrategy;
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
@@ -118,9 +118,9 @@ After creating the strategy PHP class, register it as a Symfony service.
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
- AppBundle\Asset\VersionStrategy\GulpBusterVersionStrategy:
+ App\Asset\VersionStrategy\GulpBusterVersionStrategy:
arguments:
- "%kernel.project_dir%/busters.json"
- "%%s?version=%%s"
@@ -128,7 +128,7 @@ After creating the strategy PHP class, register it as a Symfony service.
.. code-block:: xml
-
+
-
+
%kernel.project_dir%/busters.json
%%s?version=%%s
@@ -145,9 +145,9 @@ After creating the strategy PHP class, register it as a Symfony service.
.. code-block:: php
- // app/config/services.php
+ // config/services.php
use Symfony\Component\DependencyInjection\Definition;
- use AppBundle\Asset\VersionStrategy\GulpBusterVersionStrategy;
+ use App\Asset\VersionStrategy\GulpBusterVersionStrategy;
$container->autowire(GulpBusterVersionStrategy::class)
->setArguments(
@@ -169,7 +169,7 @@ the :ref:`version_strategy ` option:
framework:
# ...
assets:
- version_strategy: 'AppBundle\Asset\VersionStrategy\GulpBusterVersionStrategy'
+ version_strategy: 'App\Asset\VersionStrategy\GulpBusterVersionStrategy'
.. code-block:: xml
@@ -182,14 +182,14 @@ the :ref:`version_strategy ` option:
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
-
+
.. code-block:: php
// app/config/config.php
- use AppBundle\Asset\VersionStrategy\GulpBusterVersionStrategy;
+ use App\Asset\VersionStrategy\GulpBusterVersionStrategy;
$container->loadFromExtension('framework', array(
// ...
diff --git a/http_cache.rst b/http_cache.rst
index a2d6a9b090f..21375c4dcee 100644
--- a/http_cache.rst
+++ b/http_cache.rst
@@ -82,9 +82,9 @@ that wraps the default one (``AppKernel``). The caching Kernel *is* the reverse
proxy.
To enable caching, modify the code of your front controller. You can also make these
-changes to ``app_dev.php`` to add caching to the ``dev`` environment::
+changes to ``index.php`` to add caching to the ``dev`` environment::
- // web/app.php
+ // public/index.php
use Symfony\Component\HttpFoundation\Request;
// ...
@@ -92,7 +92,7 @@ changes to ``app_dev.php`` to add caching to the ``dev`` environment::
$kernel->loadClassCache();
// add (or uncomment) this new line!
- // wrap the default AppKernel with the AppCache one
+ // wrap the default Kernel with the AppCache one
$kernel = new AppCache($kernel);
$request = Request::createFromGlobals();
@@ -138,7 +138,7 @@ For a full list of the options and their meaning, see the
:method:`HttpCache::__construct() documentation `.
When you're in debug mode (either because your booting a ``debug`` kernel, like
-in ``app_dev.php`` *or* you manually set the ``debug`` option to true), Symfony
+in ``index.php`` *or* you manually set the ``debug`` option to true), Symfony
automatically adds an ``X-Symfony-Cache`` header to the response. Use this to get
information about cache hits and misses.
@@ -210,7 +210,7 @@ Expiration Caching
The *easiest* way to cache a response is by caching it for a specific amount of time::
- // src/AppBundle/Controller/BlogController.php
+ // src/Controller/BlogController.php
use Symfony\Component\HttpFoundation\Response;
// ...
diff --git a/http_cache/esi.rst b/http_cache/esi.rst
index c3992ac280f..512411ca57b 100644
--- a/http_cache/esi.rst
+++ b/http_cache/esi.rst
@@ -99,7 +99,7 @@ independent of the rest of the page.
.. code-block:: php
- // src/AppBundle/Controller/DefaultController.php
+ // src/Controller/DefaultController.php
// ...
class DefaultController extends Controller
@@ -126,7 +126,7 @@ matter), Symfony uses the standard ``render`` helper to configure ESI tags:
.. code-block:: twig
- {# app/Resources/views/static/about.html.twig #}
+ {# templates/static/about.html.twig #}
{# you can use a controller reference #}
{{ render_esi(controller('AppBundle:News:latest', { 'maxPerPage': 5 })) }}
@@ -136,7 +136,7 @@ matter), Symfony uses the standard ``render`` helper to configure ESI tags:
.. code-block:: html+php
-
+
render(
@@ -189,8 +189,8 @@ of the master page.
.. code-block:: php
- // src/AppBundle/Controller/NewsController.php
- namespace AppBundle\Controller;
+ // src/Controller/NewsController.php
+ namespace App\Controller;
// ...
class NewsController extends Controller
diff --git a/http_cache/validation.rst b/http_cache/validation.rst
index c3dadbeb901..97dff6f41a0 100644
--- a/http_cache/validation.rst
+++ b/http_cache/validation.rst
@@ -59,8 +59,8 @@ each ``ETag`` must be unique across all representations of the same resource.
To see a simple implementation, generate the ETag as the md5 of the content::
- // src/AppBundle/Controller/DefaultController.php
- namespace AppBundle\Controller;
+ // src/Controller/DefaultController.php
+ namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
@@ -121,13 +121,13 @@ For instance, you can use the latest update date for all the objects needed to
compute the resource representation as the value for the ``Last-Modified``
header value::
- // src/AppBundle/Controller/ArticleController.php
- namespace AppBundle\Controller;
+ // src/Controller/ArticleController.php
+ namespace App\Controller;
// ...
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
- use AppBundle\Entity\Article;
+ use App\Entity\Article;
class ArticleController extends Controller
{
@@ -181,8 +181,8 @@ Put another way, the less you do in your application to return a 304 response,
the better. The ``Response::isNotModified()`` method does exactly that by
exposing a simple and efficient pattern::
- // src/AppBundle/Controller/ArticleController.php
- namespace AppBundle\Controller;
+ // src/Controller/ArticleController.php
+ namespace App\Controller;
// ...
use Symfony\Component\HttpFoundation\Response;
diff --git a/introduction/from_flat_php_to_symfony2.rst b/introduction/from_flat_php_to_symfony2.rst
index 910ff44eed8..23a541ea46e 100644
--- a/introduction/from_flat_php_to_symfony2.rst
+++ b/introduction/from_flat_php_to_symfony2.rst
@@ -541,10 +541,10 @@ solve these problems.
Instead of re-solving common problems, you can let Symfony take care of
them for you. Here's the same sample application, now built in Symfony::
- // src/AppBundle/Controller/BlogController.php
- namespace AppBundle\Controller;
+ // src/Controller/BlogController.php
+ namespace App\Controller;
- use AppBundle\Entity\Post;
+ use App\Entity\Post;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class BlogController extends Controller
@@ -585,7 +585,7 @@ database and the Templating component to render a template and return a
.. code-block:: html+php
-
+
extend('layout.html.php') ?>
set('title', 'List of Posts') ?>
@@ -608,7 +608,7 @@ The ``layout.php`` file is nearly identical:
.. code-block:: html+php
-
+
@@ -629,12 +629,12 @@ The ``layout.php`` file is nearly identical:
When Symfony's engine (called the Kernel) boots up, it needs a map so
that it knows which controllers to execute based on the request information.
-A routing configuration map - ``app/config/routing.yml`` - provides this information
+A routing configuration map - ``config/routes.yaml`` - provides this information
in a readable format:
.. code-block:: yaml
- # app/config/routing.yml
+ # config/routes.yaml
blog_list:
path: /blog
defaults: { _controller: AppBundle:Blog:list }
@@ -644,16 +644,16 @@ in a readable format:
defaults: { _controller: AppBundle:Blog:show }
Now that Symfony is handling all the mundane tasks, the front controller
-``web/app.php`` is dead simple. And since it does so little, you'll never
+``public/index.php`` is dead simple. And since it does so little, you'll never
have to touch it::
- // web/app.php
+ // public/index.php
require_once __DIR__.'/../app/bootstrap.php';
- require_once __DIR__.'/../app/AppKernel.php';
+ require_once __DIR__.'/../src/Kernel.php';
use Symfony\Component\HttpFoundation\Request;
- $kernel = new AppKernel('prod', false);
+ $kernel = new Kernel('prod', false);
$kernel->handle(Request::createFromGlobals())->send();
The front controller's only job is to initialize Symfony's engine (called the
@@ -682,7 +682,7 @@ this:
.. code-block:: html+twig
- {# app/Resources/views/blog/list.html.twig #}
+ {# templates/blog/list.html.twig #}
{% extends "layout.html.twig" %}
{% block title %}List of Posts{% endblock %}
@@ -704,7 +704,7 @@ And rewriting ``layout.html.php`` template in Twig would look like this:
.. code-block:: html+twig
- {# app/Resources/views/layout.html.twig #}
+ {# templates/layout.html.twig #}
diff --git a/logging/formatter.rst b/logging/formatter.rst
index cb85ede0242..3131b8c79f1 100644
--- a/logging/formatter.rst
+++ b/logging/formatter.rst
@@ -14,7 +14,7 @@ configure your handler to use it:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
@@ -30,7 +30,7 @@ configure your handler to use it:
.. code-block:: xml
-
+
register(JsonFormatter::class);
// app/config/config_prod.php (or config_dev.php)
diff --git a/logging/processors.rst b/logging/processors.rst
index dfa3f863bd7..309115aa068 100644
--- a/logging/processors.rst
+++ b/logging/processors.rst
@@ -18,7 +18,7 @@ using a processor.
.. code-block:: php
- namespace AppBundle\Logger;
+ namespace App\Logger;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
@@ -55,21 +55,21 @@ information:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
monolog.formatter.session_request:
class: Monolog\Formatter\LineFormatter
arguments:
- "[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n"
- AppBundle\Logger\SessionRequestProcessor:
+ App\Logger\SessionRequestProcessor:
autowire: true
tags:
- { name: monolog.processor, method: processRecord }
.. code-block:: xml
-
+
[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%
-
+
@@ -94,8 +94,8 @@ information:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Logger\SessionRequestProcessor;
+ // config/services.php
+ use App\Logger\SessionRequestProcessor;
use Monolog\Formatter\LineFormatter;
$container
@@ -174,7 +174,7 @@ the ``monolog.processor`` tag:
# app/config/config.yml
services:
- AppBundle\Logger\SessionRequestProcessor:
+ App\Logger\SessionRequestProcessor:
autowire: true
tags:
- { name: monolog.processor, method: processRecord, handler: main }
@@ -192,7 +192,7 @@ the ``monolog.processor`` tag:
http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
-
+
@@ -219,7 +219,7 @@ the ``monolog.processor`` tag:
# app/config/config.yml
services:
- AppBundle\Logger\SessionRequestProcessor:
+ App\Logger\SessionRequestProcessor:
autowire: true
tags:
- { name: monolog.processor, method: processRecord, channel: main }
@@ -237,7 +237,7 @@ the ``monolog.processor`` tag:
http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
-
+
diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst
index f3fe1804b42..1e84d95a05d 100644
--- a/profiler/data_collector.rst
+++ b/profiler/data_collector.rst
@@ -42,8 +42,8 @@ populate the ``$this->data`` property (it takes care of serializing the
``$this->data`` property). Imagine you create a new data collector that
collects the method and accepted content types from the request::
- // src/AppBundle/DataCollector/RequestCollector.php
- namespace AppBundle\DataCollector;
+ // src/DataCollector/RequestCollector.php
+ namespace App\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpFoundation\Request;
@@ -95,7 +95,7 @@ The getters are added to give the template access to the collected information.
Enabling Custom Data Collectors
-------------------------------
-If you're using the :ref:`default services.yml configuration `
+If you're using the :ref:`default services.yaml configuration `
with ``autoconfigure``, then Symfony will automatically see your new data collector!
Your ``collect()`` method should be called next time your refresh.
@@ -227,9 +227,9 @@ to specify a tag that contains the template:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
- AppBundle\DataCollector\RequestCollector:
+ App\DataCollector\RequestCollector:
tags:
-
name: data_collector
@@ -242,7 +242,7 @@ to specify a tag that contains the template:
.. code-block:: xml
-
+
-
+
autowire(RequestCollector::class)
diff --git a/profiler/matchers.rst b/profiler/matchers.rst
index f2b9c384ba8..2e92a52a440 100644
--- a/profiler/matchers.rst
+++ b/profiler/matchers.rst
@@ -88,8 +88,8 @@ Suppose that the profiler must be enabled whenever a user with a
``ROLE_SUPER_ADMIN`` is logged in. This is the only code needed for that custom
matcher::
- // src/AppBundle/Profiler/SuperAdminMatcher.php
- namespace AppBundle\Profiler;
+ // src/Profiler/SuperAdminMatcher.php
+ namespace App\Profiler;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -111,7 +111,7 @@ matcher::
}
Then, you'll need to make sure your class is defined as as service. If you're using
-the :ref:`default services.yml configuration `,
+the :ref:`default services.yaml configuration `,
you don't need to do anything!
Once the service is registered, the only thing left to do is configure the
@@ -126,7 +126,7 @@ profiler to use this service as the matcher:
# ...
profiler:
matcher:
- service: AppBundle\Profiler\SuperAdminMatcher
+ service: App\Profiler\SuperAdminMatcher
.. code-block:: xml
@@ -143,7 +143,7 @@ profiler to use this service as the matcher:
-
+
@@ -151,7 +151,7 @@ profiler to use this service as the matcher:
.. code-block:: php
// app/config/config.php
- use AppBundle\Profiler\SuperAdminMatcher;
+ use App\Profiler\SuperAdminMatcher;
$container->loadFromExtension('framework', array(
// ...
diff --git a/quick_tour/the_architecture.rst b/quick_tour/the_architecture.rst
index ce8c9ccef9a..c91da1a814f 100644
--- a/quick_tour/the_architecture.rst
+++ b/quick_tour/the_architecture.rst
@@ -25,29 +25,29 @@ recommended structure is as follows:
Generated files (cache, logs, etc.).
``vendor/``
The third-party dependencies.
-``web/``
+``public/``
The web root directory.
-The ``web/`` Directory
-~~~~~~~~~~~~~~~~~~~~~~
+The ``public/`` Directory
+~~~~~~~~~~~~~~~~~~~~~~~~~
The web root directory is the home of all public and static files like images,
stylesheets and JavaScript files. It is also where each front controller (the
file that handles all requests to your application) lives, such as the
production controller shown here::
- // web/app.php
+ // public/index.php
require_once __DIR__.'/../var/bootstrap.php.cache';
- require_once __DIR__.'/../app/AppKernel.php';
+ require_once __DIR__.'/../src/Kernel.php';
use Symfony\Component\HttpFoundation\Request;
- $kernel = new AppKernel('prod', false);
+ $kernel = new Kernel('prod', false);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
-The controller first bootstraps the application using a kernel class (``AppKernel``
+The controller first bootstraps the application using a kernel class (``Kernel``
in this case). Then, it creates the ``Request`` object using the PHP's global
variables and passes it to the kernel. The last step is to send the response
contents returned by the kernel back to the user.
@@ -108,7 +108,7 @@ An application is made up of bundles as defined in the ``registerBundles()``
method of the ``AppKernel`` class. Each bundle is a directory that contains
a single Bundle class that describes it::
- // app/AppKernel.php
+ // src/Kernel.php
public function registerBundles()
{
$bundles = array(
diff --git a/quick_tour/the_big_picture.rst b/quick_tour/the_big_picture.rst
index 5c275cd1ae5..4aa9a648c35 100644
--- a/quick_tour/the_big_picture.rst
+++ b/quick_tour/the_big_picture.rst
@@ -36,8 +36,8 @@ And the contents displayed in the browser are usually rendered using
**templates**.
When you go to ``http://localhost:8000/app/example``, Symfony will execute
-the controller in ``src/AppBundle/Controller/DefaultController.php`` and
-render the ``app/Resources/views/default/index.html.twig`` template.
+the controller in ``src/Controller/DefaultController.php`` and
+render the ``templates/default/index.html.twig`` template.
In the following sections you'll learn in detail the inner workings of Symfony
controllers, routes and templates.
@@ -45,11 +45,11 @@ controllers, routes and templates.
Actions and Controllers
~~~~~~~~~~~~~~~~~~~~~~~
-Open the ``src/AppBundle/Controller/DefaultController.php`` file and you'll
+Open the ``src/Controller/DefaultController.php`` file and you'll
see the following code (for now, don't look at the ``@Route`` configuration
because that will be explained in the next section)::
- namespace AppBundle\Controller;
+ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
@@ -89,11 +89,11 @@ Routing
Symfony routes each request to the action that handles it by matching the
requested URL against the paths configured by the application. Open again
-the ``src/AppBundle/Controller/DefaultController.php`` file and take a look
+the ``src/Controller/DefaultController.php`` file and take a look
at the three lines of code above the ``indexAction()`` method::
- // src/AppBundle/Controller/DefaultController.php
- namespace AppBundle\Controller;
+ // src/Controller/DefaultController.php
+ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
@@ -149,14 +149,14 @@ Symfony provides some useful shortcuts to any controller extending from
the base Symfony :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`
class.
-By default, application templates are stored in the ``app/Resources/views/``
+By default, application templates are stored in the ``templates/``
directory. Therefore, the ``default/index.html.twig`` template corresponds
-to the ``app/Resources/views/default/index.html.twig``. Open that file and
+to the ``templates/default/index.html.twig``. Open that file and
you'll see the following code:
.. code-block:: html+twig
- {# app/Resources/views/default/index.html.twig #}
+ {# templates/default/index.html.twig #}
{% extends 'base.html.twig' %}
{% block body %}
@@ -212,9 +212,9 @@ executing the application on production).
When you visit the ``http://localhost:8000`` URL in your browser, you're
executing your Symfony application in the ``dev`` environment. To visit
-your application in the ``prod`` environment, visit the ``http://localhost:8000/app.php``
+your application in the ``prod`` environment, visit the ``http://localhost:8000/index.php``
URL instead. If you prefer to always show the ``dev`` environment in the
-URL, you can visit ``http://localhost:8000/app_dev.php`` URL.
+URL, you can visit ``http://localhost:8000/index.php`` URL.
The main difference between environments is that ``dev`` is optimized to
provide lots of information to the developer, which means worse application
diff --git a/quick_tour/the_controller.rst b/quick_tour/the_controller.rst
index eba1bf12bcf..edd21d87aa2 100644
--- a/quick_tour/the_controller.rst
+++ b/quick_tour/the_controller.rst
@@ -19,8 +19,8 @@ controller shortcut method to return a rendered template as result. In case
you need it, you can also create a raw ``Response`` object to return any
text content::
- // src/AppBundle/Controller/DefaultController.php
- namespace AppBundle\Controller;
+ // src/Controller/DefaultController.php
+ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
@@ -51,11 +51,11 @@ is assigned a unique name that can be used later in the controller to retrieve
each value.
Let's create a new action with route variables to show this feature in action.
-Open the ``src/AppBundle/Controller/DefaultController.php`` file and add
+Open the ``src/Controller/DefaultController.php`` file and add
a new method called ``helloAction()`` with the following content::
- // src/AppBundle/Controller/DefaultController.php
- namespace AppBundle\Controller;
+ // src/Controller/DefaultController.php
+ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
@@ -81,12 +81,12 @@ result, you'll see an error page. As you probably guessed, the cause of
this error is that we're trying to render a template
(``default/hello.html.twig``) that doesn't exist yet.
-Create the new ``app/Resources/views/default/hello.html.twig`` template
+Create the new ``templates/default/hello.html.twig`` template
with the following content:
.. code-block:: html+twig
- {# app/Resources/views/default/hello.html.twig #}
+ {# templates/default/hello.html.twig #}
{% extends 'base.html.twig' %}
{% block body %}
@@ -113,7 +113,7 @@ which stores the format requested by the user.
Tweak the ``hello`` route by adding a new ``_format`` variable with ``html``
as its default value::
- // src/AppBundle/Controller/DefaultController.php
+ // src/Controller/DefaultController.php
use Symfony\Component\Routing\Annotation\Route;
// ...
@@ -134,7 +134,7 @@ a new ``hello.xml.twig`` template:
.. code-block:: xml+php
-
+
{{ name }}
@@ -151,7 +151,7 @@ automatically choose the best ``Content-Type`` header for the response.
To restrict the formats supported by a given action, use the ``requirements``
option of the ``@Route()`` annotation::
- // src/AppBundle/Controller/DefaultController.php
+ // src/Controller/DefaultController.php
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
@@ -184,7 +184,7 @@ Redirecting
If you want to redirect the user to another page, use the ``redirectToRoute()``
method::
- // src/AppBundle/Controller/DefaultController.php
+ // src/Controller/DefaultController.php
class DefaultController extends Controller
{
/**
@@ -207,7 +207,7 @@ Errors will inevitably happen during the execution of every web application.
In the case of ``404`` errors, Symfony includes a handy shortcut that you
can use in your controllers::
- // src/AppBundle/Controller/DefaultController.php
+ // src/Controller/DefaultController.php
// ...
class DefaultController extends Controller
@@ -225,7 +225,7 @@ can use in your controllers::
For ``500`` errors, just throw a regular PHP exception inside the controller
and Symfony will transform it into a proper ``500`` error page::
- // src/AppBundle/Controller/DefaultController.php
+ // src/Controller/DefaultController.php
// ...
class DefaultController extends Controller
@@ -250,8 +250,8 @@ parameters. To get access to this information, add a new argument of type
but it must be preceded by the ``Request`` type in order to work (don't
forget to add the new ``use`` statement that imports this ``Request`` class)::
- // src/AppBundle/Controller/DefaultController.php
- namespace AppBundle\Controller;
+ // src/Controller/DefaultController.php
+ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
diff --git a/quick_tour/the_view.rst b/quick_tour/the_view.rst
index 693433805f7..ea954471978 100644
--- a/quick_tour/the_view.rst
+++ b/quick_tour/the_view.rst
@@ -106,19 +106,19 @@ it inherits from the ``base.html.twig`` template:
.. code-block:: html+twig
- {# app/Resources/views/default/index.html.twig #}
+ {# templates/default/index.html.twig #}
{% extends 'base.html.twig' %}
{% block body %}
Welcome to Symfony!
{% endblock %}
-Open the ``app/Resources/views/base.html.twig`` file that corresponds to
+Open the ``templates/base.html.twig`` file that corresponds to
the ``base.html.twig`` template and you'll find the following Twig code:
.. code-block:: html+twig
- {# app/Resources/views/base.html.twig #}
+ {# templates/base.html.twig #}
@@ -170,7 +170,7 @@ create a ``banner.html.twig`` template:
.. code-block:: twig
- {# app/Resources/views/ads/banner.html.twig #}
+ {# templates/ads/banner.html.twig #}
...
@@ -180,7 +180,7 @@ using the ``include()`` function:
.. code-block:: html+twig
- {# app/Resources/views/default/index.html.twig #}
+ {# templates/default/index.html.twig #}
{% extends 'base.html.twig' %}
{% block body %}
@@ -203,7 +203,7 @@ use the ``render()`` function:
.. code-block:: twig
- {# app/Resources/views/index.html.twig #}
+ {# templates/index.html.twig #}
{{ render(controller('AppBundle:Default:topArticles')) }}
Here, the ``render()`` and ``controller()`` functions use the special
@@ -211,7 +211,7 @@ Here, the ``render()`` and ``controller()`` functions use the special
action of the ``Default`` controller (the ``AppBundle`` part will be explained
later)::
- // src/AppBundle/Controller/DefaultController.php
+ // src/Controller/DefaultController.php
class DefaultController extends Controller
{
public function topArticlesAction()
@@ -260,7 +260,7 @@ Symfony provides the ``asset()`` function to deal with them easily:
-The ``asset()`` function looks for the web assets inside the ``web/`` directory.
+The ``asset()`` function looks for the web assets inside the ``public/`` directory.
If you store them in another directory, read
:doc:`this article `
to learn how to manage web assets.
diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst
index 1870799dc83..162fa9d0282 100644
--- a/reference/dic_tags.rst
+++ b/reference/dic_tags.rst
@@ -91,7 +91,7 @@ And then register it as a tagged service:
.. code-block:: yaml
services:
- AppBundle\Assetic\CustomWorker:
+ App\Assetic\CustomWorker:
tags: [assetic.factory_worker]
.. code-block:: xml
@@ -103,7 +103,7 @@ And then register it as a tagged service:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -111,7 +111,7 @@ And then register it as a tagged service:
.. code-block:: php
- use AppBundle\Assetic\CustomWorker;
+ use App\Assetic\CustomWorker;
$container
->register(CustomWorker::class)
@@ -151,7 +151,7 @@ Second, define a service:
.. code-block:: yaml
services:
- AppBundle\Assetic\CustomFilter:
+ App\Assetic\CustomFilter:
tags:
- { name: assetic.filter, alias: my_filter }
@@ -164,7 +164,7 @@ Second, define a service:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -172,7 +172,7 @@ Second, define a service:
.. code-block:: php
- use AppBundle\Assetic\CustomFilter;
+ use App\Assetic\CustomFilter;
$container
->register(CustomFilter::class)
@@ -246,13 +246,13 @@ services:
services:
app.mysql_lock:
- class: AppBundle\Lock\MysqlLock
+ class: App\Lock\MysqlLock
public: false
app.postgresql_lock:
- class: AppBundle\Lock\PostgresqlLock
+ class: App\Lock\PostgresqlLock
public: false
app.sqlite_lock:
- class: AppBundle\Lock\SqliteLock
+ class: App\Lock\SqliteLock
public: false
.. code-block:: xml
@@ -265,19 +265,19 @@ services:
+ class="App\Lock\MysqlLock" />
+ class="App\Lock\PostgresqlLock" />
+ class="App\Lock\SqliteLock" />
.. code-block:: php
- use AppBundle\Lock\MysqlLock;
- use AppBundle\Lock\PostgresqlLock;
- use AppBundle\Lock\SqliteLock;
+ use App\Lock\MysqlLock;
+ use App\Lock\PostgresqlLock;
+ use App\Lock\SqliteLock;
$container->register('app.mysql_lock', MysqlLock::class)->setPublic(false);
$container->register('app.postgresql_lock', PostgresqlLock::class)->setPublic(false);
@@ -316,11 +316,11 @@ the generic ``app.lock`` service can be defined as follows:
+ class="App\Lock\MysqlLock" />
+ class="App\Lock\PostgresqlLock" />
+ class="App\Lock\SqliteLock" />
@@ -330,9 +330,9 @@ the generic ``app.lock`` service can be defined as follows:
.. code-block:: php
- use AppBundle\Lock\MysqlLock;
- use AppBundle\Lock\PostgresqlLock;
- use AppBundle\Lock\SqliteLock;
+ use App\Lock\MysqlLock;
+ use App\Lock\PostgresqlLock;
+ use App\Lock\SqliteLock;
$container->register('app.mysql_lock', MysqlLock::class)->setPublic(false);
$container->register('app.postgresql_lock', PostgresqlLock::class)->setPublic(false);
@@ -447,8 +447,8 @@ files during the cache clearing process.
In order to register your custom cache clearer, first you must create a
service class::
- // src/AppBundle/Cache/MyClearer.php
- namespace AppBundle\Cache;
+ // src/Cache/MyClearer.php
+ namespace App\Cache;
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
@@ -460,7 +460,7 @@ service class::
}
}
-If you're using the :ref:`default services.yml configuration `,
+If you're using the :ref:`default services.yaml configuration `,
your service will be automatically tagged with ``kernel.cache_clearer``. But, you
can also register it manually:
@@ -469,7 +469,7 @@ can also register it manually:
.. code-block:: yaml
services:
- AppBundle\Cache\MyClearer:
+ App\Cache\MyClearer:
tags: [kernel.cache_clearer]
.. code-block:: xml
@@ -481,7 +481,7 @@ can also register it manually:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -489,7 +489,7 @@ can also register it manually:
.. code-block:: php
- use AppBundle\Cache\MyClearer;
+ use App\Cache\MyClearer;
$container
->register(MyClearer::class)
@@ -519,7 +519,7 @@ To register your own cache warmer, first create a service that implements
the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` interface::
// src/Acme/MainBundle/Cache/MyCustomWarmer.php
- namespace AppBundle\Cache;
+ namespace App\Cache;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
@@ -541,7 +541,7 @@ application without calling this cache warmer. In Symfony, optional warmers
are always executed by default (you can change this by using the
``--no-optional-warmers`` option when executing the command).
-If you're using the :ref:`default services.yml configuration `,
+If you're using the :ref:`default services.yaml configuration `,
your service will be automatically tagged with ``kernel.cache_warmer``. But, you
can also register it manually:
@@ -550,7 +550,7 @@ can also register it manually:
.. code-block:: yaml
services:
- AppBundle\Cache\MyCustomWarmer:
+ App\Cache\MyCustomWarmer:
tags:
- { name: kernel.cache_warmer, priority: 0 }
@@ -563,7 +563,7 @@ can also register it manually:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -571,7 +571,7 @@ can also register it manually:
.. code-block:: php
- use AppBundle\Cache\MyCustomWarmer;
+ use App\Cache\MyCustomWarmer;
$container
->register(MyCustomWarmer::class)
@@ -659,7 +659,7 @@ channel when injecting the logger in a service.
.. code-block:: yaml
services:
- AppBundle\Log\CustomLogger:
+ App\Log\CustomLogger:
arguments: ['@logger']
tags:
- { name: monolog.logger, channel: acme }
@@ -673,7 +673,7 @@ channel when injecting the logger in a service.
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -682,7 +682,7 @@ channel when injecting the logger in a service.
.. code-block:: php
- use AppBundle\Log\CustomLogger;
+ use App\Log\CustomLogger;
use Symfony\Component\DependencyInjection\Reference;
$container->register(CustomLogger::class)
@@ -840,7 +840,7 @@ of your configuration and tag it with ``routing.loader``:
.. code-block:: yaml
services:
- AppBundle\Routing\CustomLoader:
+ App\Routing\CustomLoader:
tags: [routing.loader]
.. code-block:: xml
@@ -852,7 +852,7 @@ of your configuration and tag it with ``routing.loader``:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -860,7 +860,7 @@ of your configuration and tag it with ``routing.loader``:
.. code-block:: php
- use AppBundle\Routing\CustomLoader;
+ use App\Routing\CustomLoader;
$container
->register(CustomLoader::class)
@@ -981,7 +981,7 @@ templates):
.. code-block:: yaml
services:
- AppBundle\Templating\AppHelper:
+ App\Templating\AppHelper:
tags:
- { name: templating.helper, alias: alias_name }
@@ -994,7 +994,7 @@ templates):
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -1002,7 +1002,7 @@ templates):
.. code-block:: php
- use AppBundle\Templating\AppHelper;
+ use App\Templating\AppHelper;
$container->register(AppHelper::class)
->addTag('templating.helper', array('alias' => 'alias_name'))
@@ -1030,7 +1030,7 @@ Now, register your loader as a service and tag it with ``translation.loader``:
.. code-block:: yaml
services:
- AppBundle\Translation\MyCustomLoader:
+ App\Translation\MyCustomLoader:
tags:
- { name: translation.loader, alias: bin }
@@ -1043,7 +1043,7 @@ Now, register your loader as a service and tag it with ``translation.loader``:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -1051,7 +1051,7 @@ Now, register your loader as a service and tag it with ``translation.loader``:
.. code-block:: php
- use AppBundle\Translation\MyCustomLoader;
+ use App\Translation\MyCustomLoader;
$container
->register(MyCustomLoader::class)
@@ -1144,7 +1144,7 @@ required option: ``alias``, which defines the name of the extractor::
.. code-block:: php
- use AppBundle\Translation\CustomExtractor;
+ use App\Translation\CustomExtractor;
$container->register(CustomExtractor::class)
->addTag('translation.extractor', array('alias' => 'foo'));
@@ -1180,7 +1180,7 @@ This is the name that's used to determine which dumper should be used.
.. code-block:: yaml
services:
- AppBundle\Translation\JsonFileDumper:
+ App\Translation\JsonFileDumper:
tags:
- { name: translation.dumper, alias: json }
@@ -1193,7 +1193,7 @@ This is the name that's used to determine which dumper should be used.
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -1201,7 +1201,7 @@ This is the name that's used to determine which dumper should be used.
.. code-block:: php
- use AppBundle\Translation\JsonFileDumper;
+ use App\Translation\JsonFileDumper;
$container->register(JsonFileDumper::class)
->addTag('translation.dumper', array('alias' => 'json'));
@@ -1220,7 +1220,7 @@ twig.extension
To enable a Twig extension, add it as a regular service in one of your
configuration and tag it with ``twig.extension``. If you're using the
-:ref:`default services.yml configuration `,
+:ref:`default services.yaml configuration `,
the service is auto-registered and auto-tagged. But, you can also register it manually:
.. configuration-block::
@@ -1228,7 +1228,7 @@ the service is auto-registered and auto-tagged. But, you can also register it ma
.. code-block:: yaml
services:
- AppBundle\Twig\AppExtension:
+ App\Twig\AppExtension:
tags: [twig.extension]
.. code-block:: xml
@@ -1240,7 +1240,7 @@ the service is auto-registered and auto-tagged. But, you can also register it ma
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -1248,7 +1248,7 @@ the service is auto-registered and auto-tagged. But, you can also register it ma
.. code-block:: php
- use AppBundle\Twig\AppExtension;
+ use App\Twig\AppExtension;
$container
->register(AppExtension::class)
@@ -1305,7 +1305,7 @@ By default, Symfony uses only one `Twig Loader`_ -
to load Twig templates from another resource, you can create a service for
the new loader and tag it with ``twig.loader``.
-If you use the :ref:`default services.yml configuration `,
+If you use the :ref:`default services.yaml configuration `,
the service will be automatically tagged thanks to autoconfiguration. But, you can
also register it manually:
@@ -1314,7 +1314,7 @@ also register it manually:
.. code-block:: yaml
services:
- AppBundle\Twig\CustomLoader:
+ App\Twig\CustomLoader:
tags:
- { name: twig.loader, priority: 0 }
@@ -1327,7 +1327,7 @@ also register it manually:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -1335,7 +1335,7 @@ also register it manually:
.. code-block:: php
- use AppBundle\Twig\CustomLoader;
+ use App\Twig\CustomLoader;
$container
->register(CustomLoader::class)
diff --git a/routing.rst b/routing.rst
index e8b04b4e04f..bd4198eb0e3 100644
--- a/routing.rst
+++ b/routing.rst
@@ -36,8 +36,8 @@ The route is simple:
.. code-block:: php-annotations
- // src/AppBundle/Controller/BlogController.php
- namespace AppBundle\Controller;
+ // src/Controller/BlogController.php
+ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
@@ -70,7 +70,7 @@ The route is simple:
.. code-block:: yaml
- # app/config/routing.yml
+ # config/routes.yaml
blog_list:
path: /blog
defaults: { _controller: AppBundle:Blog:list }
@@ -81,7 +81,7 @@ The route is simple:
.. code-block:: xml
-
+
`. It follows a pattern that
points to a specific PHP class and method, in this case the
``AppBundle\Controller\BlogController::listAction`` and
- ``AppBundle\Controller\BlogController::showAction`` methods.
+ ``App\Controller\BlogController::showAction`` methods.
This is the goal of the Symfony router: to map the URL of a request to a
controller. Along the way, you'll learn all sorts of tricks that make mapping
@@ -170,8 +170,8 @@ To fix this, add a *requirement* that the ``{page}`` wildcard can *only* match n
.. code-block:: php-annotations
- // src/AppBundle/Controller/BlogController.php
- namespace AppBundle\Controller;
+ // src/Controller/BlogController.php
+ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
@@ -197,7 +197,7 @@ To fix this, add a *requirement* that the ``{page}`` wildcard can *only* match n
.. code-block:: yaml
- # app/config/routing.yml
+ # config/routes.yaml
blog_list:
path: /blog/{page}
defaults: { _controller: AppBundle:Blog:list }
@@ -209,7 +209,7 @@ To fix this, add a *requirement* that the ``{page}`` wildcard can *only* match n
.. code-block:: xml
-
+
+
+
+
-
@@ -169,7 +169,7 @@ Now define a service for the ``ExtraLoader``:
.. code-block:: php
- use AppBundle\Routing\ExtraLoader;
+ use App\Routing\ExtraLoader;
$container
->autowire(ExtraLoader::class)
@@ -191,7 +191,7 @@ What remains to do is adding a few lines to the routing configuration:
.. code-block:: yaml
- # app/config/routing.yml
+ # config/routes.yaml
app_extra:
resource: .
type: extra
@@ -209,7 +209,7 @@ What remains to do is adding a few lines to the routing configuration:
.. code-block:: php
- // app/config/routing.php
+ // config/routes.php
use Symfony\Component\Routing\RouteCollection;
$collection = new RouteCollection();
@@ -244,8 +244,8 @@ Whenever you want to load another resource - for instance a YAML routing
configuration file - you can call the
:method:`Symfony\\Component\\Config\\Loader\\Loader::import` method::
- // src/AppBundle/Routing/AdvancedLoader.php
- namespace AppBundle\Routing;
+ // src/Routing/AdvancedLoader.php
+ namespace App\Routing;
use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\RouteCollection;
diff --git a/routing/external_resources.rst b/routing/external_resources.rst
index 4bde4c245f5..cb4600529c6 100644
--- a/routing/external_resources.rst
+++ b/routing/external_resources.rst
@@ -4,7 +4,7 @@
How to Include External Routing Resources
=========================================
-All routes are loaded via a single configuration file - usually ``app/config/routing.yml``
+All routes are loaded via a single configuration file - usually ``config/routes.yaml``
(see :ref:`routing-creating-routes`). However, if you use routing annotations,
you'll need to point the router to the controllers with the annotations.
This can be done by "importing" directories into the routing configuration:
@@ -13,14 +13,14 @@ This can be done by "importing" directories into the routing configuration:
.. code-block:: yaml
- # app/config/routing.yml
+ # config/routes.yaml
app:
resource: '@AppBundle/Controller/'
type: annotation # required to enable the Annotation reader for this resource
.. code-block:: xml
-
+
+
+
import('@AppBundle/Controller/', 'annotation');
diff --git a/routing/extra_information.rst b/routing/extra_information.rst
index 3032b47119d..cdf35bad73b 100644
--- a/routing/extra_information.rst
+++ b/routing/extra_information.rst
@@ -13,7 +13,7 @@ to your controller, and as attributes of the ``Request`` object:
.. code-block:: yaml
- # app/config/routing.yml
+ # config/routes.yaml
blog:
path: /blog/{page}
defaults:
@@ -23,7 +23,7 @@ to your controller, and as attributes of the ``Request`` object:
.. code-block:: xml
-
+
+
+
+
+
+
+
+
+
+
+
+
+
`,
+If you're using the :ref:`default services.yaml configuration `,
you're done! Symfony will automatically know about your new service. You can then
configure it under your firewall:
@@ -44,20 +44,20 @@ configure it under your firewall:
main:
# ...
- access_denied_handler: AppBundle\Security\AccessDeniedHandler
+ access_denied_handler: App\Security\AccessDeniedHandler
.. code-block:: xml
- AppBundle\Security\AccessDeniedHandler
+ App\Security\AccessDeniedHandler
.. code-block:: php
// app/config/security.php
- use AppBundle\Security\AccessDeniedHandler;
+ use App\Security\AccessDeniedHandler;
$container->loadFromExtension('security', array(
'firewalls' => array(
diff --git a/security/acl.rst b/security/acl.rst
index ec95f04acc9..8f06329fc39 100644
--- a/security/acl.rst
+++ b/security/acl.rst
@@ -119,8 +119,8 @@ Creating an ACL and Adding an ACE
.. code-block:: php
- // src/AppBundle/Controller/BlogController.php
- namespace AppBundle\Controller;
+ // src/Controller/BlogController.php
+ namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
@@ -187,7 +187,7 @@ Checking Access
.. code-block:: php
- // src/AppBundle/Controller/BlogController.php
+ // src/Controller/BlogController.php
// ...
@@ -245,7 +245,7 @@ added above:
.. code-block:: php
- $identity = new UserSecurityIdentity('johannes', 'AppBundle\Entity\User');
+ $identity = new UserSecurityIdentity('johannes', 'App\Entity\User');
$acl->insertObjectAce($identity, $mask);
The user is now allowed to view, edit, delete, and un-delete objects.
diff --git a/security/api_key_authentication.rst b/security/api_key_authentication.rst
index 3ac4a6ef6f6..897792c90e9 100644
--- a/security/api_key_authentication.rst
+++ b/security/api_key_authentication.rst
@@ -24,10 +24,10 @@ Your exact situation may differ, but in this example, a token is read
from an ``apikey`` query parameter, the proper username is loaded from that
value and then a User object is created::
- // src/AppBundle/Security/ApiKeyAuthenticator.php
- namespace AppBundle\Security;
+ // src/Security/ApiKeyAuthenticator.php
+ namespace App\Security;
- use AppBundle\Security\ApiKeyUserProvider;
+ use App\Security\ApiKeyUserProvider;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -163,8 +163,8 @@ used by Symfony's core user provider system).
The ``$userProvider`` might look something like this::
- // src/AppBundle/Security/ApiKeyUserProvider.php
- namespace AppBundle\Security;
+ // src/Security/ApiKeyUserProvider.php
+ namespace App\Security;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\User;
@@ -209,7 +209,7 @@ The ``$userProvider`` might look something like this::
}
Next, make sure this class is registered as a service. If you're using the
-:ref:`default services.yml configuration `,
+:ref:`default services.yaml configuration `,
that happens automatically. A little later, you'll reference this service in
your :ref:`security.yml configuration `.
@@ -251,8 +251,8 @@ need to implement the :class:`Symfony\\Component\\Security\\Http\\Authentication
Authenticator. This will provide a method ``onAuthenticationFailure()`` which
you can use to create an error ``Response``::
- // src/AppBundle/Security/ApiKeyAuthenticator.php
- namespace AppBundle\Security;
+ // src/Security/ApiKeyAuthenticator.php
+ namespace App\Security;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
@@ -281,7 +281,7 @@ Configuration
-------------
Once you have your ``ApiKeyAuthenticator`` all setup, you need to register
-it as a service. If you're using the :ref:`default services.yml configuration `,
+it as a service. If you're using the :ref:`default services.yaml configuration `,
that happens automatically.
The last step is to activate your authenticator and custom user provider in the
@@ -298,14 +298,14 @@ and ``provider`` keys:
providers:
api_key_user_provider:
- id: AppBundle\Security\ApiKeyUserProvider
+ id: App\Security\ApiKeyUserProvider
firewalls:
main:
pattern: ^/api
stateless: true
simple_preauth:
- authenticator: AppBundle\Security\ApiKeyAuthenticator
+ authenticator: App\Security\ApiKeyAuthenticator
provider: api_key_user_provider
.. code-block:: xml
@@ -320,14 +320,14 @@ and ``provider`` keys:
-
+
-
+
@@ -337,8 +337,8 @@ and ``provider`` keys:
// app/config/security.php
// ...
- use AppBundle\Security\ApiKeyAuthenticator;
- use AppBundle\Security\ApiKeyUserProvider;
+ use App\Security\ApiKeyAuthenticator;
+ use App\Security\ApiKeyUserProvider;
$container->loadFromExtension('security', array(
'providers' => array(
@@ -473,7 +473,7 @@ case the API key (i.e. ``$token->getCredentials()``) - are not stored in the ses
for security reasons. To take advantage of the session, update ``ApiKeyAuthenticator``
to see if the stored token has a valid User object that can be used::
- // src/AppBundle/Security/ApiKeyAuthenticator.php
+ // src/Security/ApiKeyAuthenticator.php
// ...
class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface
@@ -537,7 +537,7 @@ stored in the database, then you may want to re-query for a fresh version
of the user to make sure it's not out-of-date. But regardless of your requirements,
``refreshUser()`` should now return the User object::
- // src/AppBundle/Security/ApiKeyUserProvider.php
+ // src/Security/ApiKeyUserProvider.php
// ...
class ApiKeyUserProvider implements UserProviderInterface
@@ -577,7 +577,7 @@ a certain URL (e.g. the redirect URL in OAuth).
Fortunately, handling this situation is easy: just check to see what the
current URL is before creating the token in ``createToken()``::
- // src/AppBundle/Security/ApiKeyAuthenticator.php
+ // src/Security/ApiKeyAuthenticator.php
// ...
use Symfony\Component\Security\Http\HttpUtils;
diff --git a/security/csrf_in_login_form.rst b/security/csrf_in_login_form.rst
index b7fc2ded46a..79230f10062 100644
--- a/security/csrf_in_login_form.rst
+++ b/security/csrf_in_login_form.rst
@@ -132,7 +132,7 @@ using the login form:
.. code-block:: html+twig
- {# src/AppBundle/Resources/views/Security/login.html.twig #}
+ {# templates/security/login.html.twig #}
{# ... #}
@@ -485,8 +485,8 @@ pass here. No problem! In your configuration, you can explicitly set this argume
.. code-block:: php
- // app/config/services.php
- use AppBundle\Updates\SiteUpdateManager;
+ // config/services.php
+ use App\Updates\SiteUpdateManager;
use Symfony\Component\DependencyInjection\Definition;
// Same as before
@@ -498,7 +498,7 @@ pass here. No problem! In your configuration, you can explicitly set this argume
->setPublic(false)
;
- $this->registerClasses($definition, 'AppBundle\\', '../../src/AppBundle/*', '../../src/AppBundle/{Entity,Repository}');
+ $this->registerClasses($definition, 'App\\', '../../src/*', '../../src/{Entity,Repository}');
// Explicitly configure the service
$container->getDefinition(SiteUpdateManager::class)
@@ -530,20 +530,20 @@ and reference it with the ``%parameter_name%`` syntax:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
parameters:
admin_email: manager@example.com
services:
# ...
- AppBundle\Updates\SiteUpdateManager:
+ App\Updates\SiteUpdateManager:
arguments:
$adminEmail: '%admin_email%'
.. code-block:: xml
-
+
-
+
%admin_email%
@@ -565,8 +565,8 @@ and reference it with the ``%parameter_name%`` syntax:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Updates\SiteUpdateManager;
+ // config/services.php
+ use App\Updates\SiteUpdateManager;
$container->setParameter('admin_email', 'manager@example.com');
$container->autowire(SiteUpdateManager::class)
@@ -613,7 +613,7 @@ Choose a Specific Service
The ``MessageGenerator`` service created earlier requires a ``LoggerInterface`` argument::
- // src/AppBundle/Service/MessageGenerator.php
+ // src/Service/MessageGenerator.php
// ...
use Psr\Log\LoggerInterface;
@@ -641,18 +641,18 @@ But, you can control this and pass in a different logger:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ... same code as before
# explicitly configure the service
- AppBundle\Service\MessageGenerator:
+ App\Service\MessageGenerator:
arguments:
$logger: '@monolog.logger.request'
.. code-block:: xml
-
+
-
+
@@ -672,8 +672,8 @@ But, you can control this and pass in a different logger:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Service\MessageGenerator;
+ // config/services.php
+ use App\Service\MessageGenerator;
use Symfony\Component\DependencyInjection\Reference;
$container->autowire(MessageGenerator::class)
@@ -695,7 +695,7 @@ service whose id is ``monolog.logger.request``.
The autowire Option
-------------------
-Above, the ``services.yml`` file has ``autowire: true`` in the ``_defaults`` section
+Above, the ``services.yaml`` file has ``autowire: true`` in the ``_defaults`` section
so that it applies to all services defined in that file. With this setting, you're
able to type-hint arguments in the ``__construct()`` method of your services and
the container will automatically pass you the correct arguments. This entire entry
@@ -711,7 +711,7 @@ The autoconfigure Option
.. versionadded:: 3.3
The ``autoconfigure`` option was added in Symfony 3.3.
-Above, the ``services.yml`` file has ``autoconfigure: true`` in the ``_defaults``
+Above, the ``services.yaml`` file has ``autoconfigure: true`` in the ``_defaults``
section so that it applies to all services defined in that file. With this setting,
the container will automatically apply certain configuration to your services, based
on your service's *class*. This is mostly used to *auto-tag* your services.
@@ -723,16 +723,16 @@ as a service, and :doc:`tag ` it with ``twig.extension`
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
- AppBundle\Twig\MyTwigExtension:
+ App\Twig\MyTwigExtension:
tags: [twig.extension]
.. code-block:: xml
-
+
` it with ``twig.extension`
-
+
@@ -750,14 +750,14 @@ as a service, and :doc:`tag ` it with ``twig.extension`
.. code-block:: php
- // app/config/services.php
- use AppBundle\Twig\MyTwigExtension;
+ // config/services.php
+ use App\Twig\MyTwigExtension;
$container->autowire(MyTwigExtension::class)
->addTag('twig.extension');
But, with ``autoconfigure: true``, you don't need the tag. In fact, if you're using
-the :ref:`Symfony Standard Edition services.yml config `,
+the :ref:`Symfony Standard Edition services.yaml config `,
you don't need to do *anything*: the service will be automatically loaded. Then,
``autoconfigure`` will add the ``twig.extension`` tag *for* you, because your class
implements ``Twig_ExtensionInterface``. And thanks to ``autowire``, you can even add
@@ -771,14 +771,14 @@ if you need to.
Public Versus Private Services
------------------------------
-Thanks to the ``_defaults`` section in ``services.yml``, every service defined in
+Thanks to the ``_defaults`` section in ``services.yaml``, every service defined in
this file is ``public: false`` by default:
.. configuration-block::
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# default configuration for services in *this* file
_defaults:
@@ -787,7 +787,7 @@ this file is ``public: false`` by default:
.. code-block:: xml
-
+
+
-
+
@@ -857,27 +857,27 @@ key. For example, the default Symfony configuration contains this:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
# the namespace prefix for classes (must end in \)
- AppBundle\:
+ App\:
# create services for all the classes found in this directory...
- resource: '../../src/AppBundle/*'
+ resource: '../../src/*'
# ...except for the classes located in these directories
- exclude: '../../src/AppBundle/{Entity,Repository}'
+ exclude: '../../src/{Entity,Repository}'
# these were imported above, but we want to add some extra config
- AppBundle\Controller\:
- resource: '../../src/AppBundle/Controller'
+ App\Controller\:
+ resource: '../../src/Controller'
# apply some configuration to these services
public: true
tags: ['controller.service_arguments']
.. code-block:: xml
-
+
-
+
-
+
@@ -897,7 +897,7 @@ key. For example, the default Symfony configuration contains this:
.. code-block:: php
- // app/config/services.php
+ // config/services.php
use Symfony\Component\DependencyInjection\Definition;
// To use as default template
@@ -909,7 +909,7 @@ key. For example, the default Symfony configuration contains this:
->setPublic(false)
;
- $this->registerClasses($definition, 'AppBundle\\', '../../src/AppBundle/*', '../../src/AppBundle/{Entity,Repository}');
+ $this->registerClasses($definition, 'App\\', '../../src/*', '../../src/{Entity,Repository}');
// Changes default config
$definition
@@ -918,7 +918,7 @@ key. For example, the default Symfony configuration contains this:
;
// $this is a reference to the current loader
- $this->registerClasses($definition, 'AppBundle\\Controller\\', '../../src/AppBundle/Controller/*');
+ $this->registerClasses($definition, 'App\\Controller\\', '../../src/Controller/*');
.. tip::
@@ -965,36 +965,36 @@ admin email. In this case, each needs to have a unique service id:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
# this is the service's id
site_update_manager.superadmin:
- class: AppBundle\Updates\SiteUpdateManager
+ class: App\Updates\SiteUpdateManager
# you CAN still use autowiring: we just want to show what it looks like without
autowire: false
# manually wire all arguments
arguments:
- - '@AppBundle\Service\MessageGenerator'
+ - '@App\Service\MessageGenerator'
- '@mailer'
- 'superadmin@example.com'
site_update_manager.normal_users:
- class: AppBundle\Updates\SiteUpdateManager
+ class: App\Updates\SiteUpdateManager
autowire: false
arguments:
- - '@AppBundle\Service\MessageGenerator'
+ - '@App\Service\MessageGenerator'
- '@mailer'
- 'contact@example.com'
# Create an alias, so that - by default - if you type-hint SiteUpdateManager,
# the site_update_manager.superadmin will be used
- AppBundle\Updates\SiteUpdateManager: '@site_update_manager.superadmin'
+ App\Updates\SiteUpdateManager: '@site_update_manager.superadmin'
.. code-block:: xml
-
+
-
-
+
+
superadmin@example.com
-
-
+
+
contact@example.com
-
+
.. code-block:: php
- // app/config/services.php
- use AppBundle\Updates\SiteUpdateManager;
- use AppBundle\Service\MessageGenerator;
+ // config/services.php
+ use App\Updates\SiteUpdateManager;
+ use App\Service\MessageGenerator;
use Symfony\Component\DependencyInjection\Reference;
$container->register('site_update_manager.superadmin', SiteUpdateManager::class)
@@ -1067,5 +1067,5 @@ Learn more
/service_container/*
.. _`service-oriented architecture`: https://en.wikipedia.org/wiki/Service-oriented_architecture
-.. _`Symfony Standard Edition (version 3.3) services.yml`: https://github.com/symfony/symfony-standard/blob/3.3/app/config/services.yml
+.. _`Symfony Standard Edition (version 3.3) services.yaml`: https://github.com/symfony/symfony-standard/blob/3.3/app/config/services.yml
.. _`glob pattern`: https://en.wikipedia.org/wiki/Glob_(programming)
diff --git a/service_container/3.3-di-changes.rst b/service_container/3.3-di-changes.rst
index 2ba6a67156f..daa5f7d6a99 100644
--- a/service_container/3.3-di-changes.rst
+++ b/service_container/3.3-di-changes.rst
@@ -1,7 +1,7 @@
The Symfony 3.3 DI Container Changes Explained (autowiring, _defaults, etc)
===========================================================================
-If you look at the ``services.yml`` file in a new Symfony 3.3 project, you'll
+If you look at the ``services.yaml`` file in a new Symfony 3.3 project, you'll
notice some big changes: ``_defaults``, ``autowiring``, ``autoconfigure`` and more.
These features are designed to *automate* configuration and make development faster,
without sacrificing predictability, which is very important! Another goal is to make
@@ -24,17 +24,17 @@ need to actually change your configuration files to use them.
.. _`service-33-default_definition`:
-The new Default services.yml File
----------------------------------
+The new Default services.yaml File
+----------------------------------
-To understand the changes, look at the new default ``services.yml`` file in the
+To understand the changes, look at the new default ``services.yaml`` file in the
Symfony Standard Edition:
.. configuration-block::
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# default configuration for services in *this* file
_defaults:
@@ -48,26 +48,26 @@ Symfony Standard Edition:
# makes classes in src/AppBundle available to be used as services
# this creates a service per class whose id is the fully-qualified class name
- AppBundle\:
- resource: '../../src/AppBundle/*'
+ App\:
+ resource: '../../src/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
- exclude: '../../src/AppBundle/{Entity,Repository}'
+ exclude: '../../src/{Entity,Repository}'
# controllers are imported separately to make sure they're public
# and have a tag that allows actions to type-hint services
- AppBundle\Controller\:
- resource: '../../src/AppBundle/Controller'
+ App\Controller\:
+ resource: '../../src/Controller'
tags: ['controller.service_arguments']
# add more services, or override services that need manual wiring
- # AppBundle\Service\ExampleService:
+ # App\Service\ExampleService:
# arguments:
# $someArgument: 'some_value'
.. code-block:: xml
-
+
-
+
-
+
@@ -89,7 +89,7 @@ Symfony Standard Edition:
.. code-block:: php
- // app/config/services.php
+ // config/services.php
use Symfony\Component\DependencyInjection\Definition;
// To use as default template
@@ -101,7 +101,7 @@ Symfony Standard Edition:
->setPublic(false)
;
- $this->registerClasses($definition, 'AppBundle\\', '../../src/AppBundle/*', '../../src/AppBundle/{Entity,Repository}');
+ $this->registerClasses($definition, 'App\\', '../../src/*', '../../src/{Entity,Repository}');
// Changes default config
$definition
@@ -109,7 +109,7 @@ Symfony Standard Edition:
;
// $this is a reference to the current loader
- $this->registerClasses($definition, 'AppBundle\\Controller\\', '../../src/AppBundle/Controller/*');
+ $this->registerClasses($definition, 'App\\Controller\\', '../../src/Controller/*');
// add more services, or override services that need manual wiring
@@ -132,21 +132,21 @@ thanks to the following config:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
# makes classes in src/AppBundle available to be used as services
# this creates a service per class whose id is the fully-qualified class name
- AppBundle\:
- resource: '../../src/AppBundle/*'
+ App\:
+ resource: '../../src/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
- exclude: '../../src/AppBundle/{Entity,Repository}'
+ exclude: '../../src/{Entity,Repository}'
.. code-block:: xml
-
+
-
+
.. code-block:: php
- // app/config/services.php
+ // config/services.php
use Symfony\Component\DependencyInjection\Definition;
// To use as default template
@@ -174,9 +174,9 @@ thanks to the following config:
->setPublic(false)
;
- $this->registerClasses($definition, 'AppBundle\\', '../../src/AppBundle/*', '../../src/AppBundle/{Entity,Repository}');
+ $this->registerClasses($definition, 'App\\', '../../src/*', '../../src/{Entity,Repository}');
-This means that every class in ``src/AppBundle/`` is *available* to be used as a
+This means that every class in ``src/`` is *available* to be used as a
service. And thanks to the ``_defaults`` section at the top of the file, all of
these services are **autowired** and **private** (i.e. ``public: false``).
@@ -191,7 +191,7 @@ to determine most arguments automatically. But, you can always override the serv
and :ref:`manually configure arguments ` or anything
else special about your service.
- But wait, if I have some model (non-service) classes in my ``src/AppBundle/``
+ But wait, if I have some model (non-service) classes in my ``src/``
directory, doesn't this mean that *they* will also be registered as services?
Isn't that a problem?
@@ -223,19 +223,19 @@ service as an argument to another with the following config:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
app.invoice_generator:
- class: AppBundle\Service\InvoiceGenerator
+ class: App\Service\InvoiceGenerator
app.invoice_mailer:
- class: AppBundle\Service\InvoiceMailer
+ class: App\Service\InvoiceMailer
arguments:
- '@app.invoice_generator'
.. code-block:: xml
-
+
+ class="App\Service\InvoiceGenerator" />
+ class="App\Service\InvoiceMailer">
@@ -256,9 +256,9 @@ service as an argument to another with the following config:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Service\InvoiceGenerator;
- use AppBundle\Service\InvoiceMailer;
+ // config/services.php
+ use App\Service\InvoiceGenerator;
+ use App\Service\InvoiceMailer;
use Symfony\Component\DependencyInjection\Reference;
$container->register('app.invoice_generator', InvoiceGenerator::class);
@@ -272,7 +272,7 @@ id's were the main way that you configured things.
But in Symfony 3.3, thanks to autowiring, all you need to do is type-hint the
argument with ``InvoiceGenerator``::
- // src/AppBundle/Service/InvoiceMailer.php
+ // src/Service/InvoiceMailer.php
// ...
class InvoiceMailer
@@ -340,19 +340,19 @@ The third big change is that, in a new Symfony 3.3 project, your controllers are
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
# controllers are imported separately to make sure they're public
# and have a tag that allows actions to type-hint services
- AppBundle\Controller\:
- resource: '../../src/AppBundle/Controller'
+ App\Controller\:
+ resource: '../../src/Controller'
tags: ['controller.service_arguments']
.. code-block:: xml
-
+
-
+
@@ -370,11 +370,11 @@ The third big change is that, in a new Symfony 3.3 project, your controllers are
.. code-block:: php
- // app/config/services.php
+ // config/services.php
// ...
- $this->registerClasses($definition, 'AppBundle\\Controller\\', '../../src/AppBundle/Controller/*');
+ $this->registerClasses($definition, 'App\\Controller\\', '../../src/Controller/*');
But, you might not even notice this. First, your controllers *can* still extend
the same base ``Controller`` class or a new :ref:`AbstractController `.
@@ -418,7 +418,7 @@ The fourth big change is the ``autoconfigure`` key, which is set to ``true`` und
this file. For example, suppose you want to create an event subscriber. First, you
create the class::
- // src/AppBundle/EventSubscriber/SetHeaderSusbcriber.php
+ // src/EventSubscriber/SetHeaderSusbcriber.php
// ...
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -441,7 +441,7 @@ create the class::
}
Great! In Symfony 3.2 or lower, you would now need to register this as a service
-in ``services.yml`` and tag it with ``kernel.event_subscriber``. In Symfony 3.3,
+in ``services.yaml`` and tag it with ``kernel.event_subscriber``. In Symfony 3.3,
you're already done! The service is :ref:`automatically registered `.
And thanks to ``autoconfigure``, Symfony automatically tags the service because
it implements ``EventSubscriberInterface``.
@@ -452,7 +452,7 @@ In this case, you've created a class that implements ``EventSubscriberInterface`
and registered it as a service. This is more than enough for the container to know
that you want this to be used as an event subscriber: more configuration is not needed.
And the tags system is its own, Symfony-specific mechanism. And of course, you can
-always set ``autoconfigure`` to ``false`` in ``services.yml``, or disable it for a specific
+always set ``autoconfigure`` to ``false`` in ``services.yaml``, or disable it for a specific
service.
Does this mean tags are dead? Does this work for all tags?
@@ -484,18 +484,18 @@ inherited from an abstract definition:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
_instanceof:
- AppBundle\Domain\LoaderInterface:
+ App\Domain\LoaderInterface:
public: true
tags: ['app.domain_loader']
.. code-block:: xml
-
+
-
+
@@ -513,8 +513,8 @@ inherited from an abstract definition:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Domain\LoaderInterface;
+ // config/services.php
+ use App\Domain\LoaderInterface;
// ...
@@ -546,23 +546,23 @@ Ready to upgrade your existing project? Great! Suppose you have the following co
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
app.github_notifier:
- class: AppBundle\Service\GitHubNotifier
+ class: App\Service\GitHubNotifier
arguments:
- '@app.api_client_github'
markdown_transformer:
- class: AppBundle\Service\MarkdownTransformer
+ class: App\Service\MarkdownTransformer
app.api_client_github:
- class: AppBundle\Service\ApiClient
+ class: App\Service\ApiClient
arguments:
- 'https://api.github.com'
app.api_client_sl_connect:
- class: AppBundle\Service\ApiClient
+ class: App\Service\ApiClient
arguments:
- 'https://connect.sensiolabs.com/api'
@@ -576,7 +576,7 @@ Start by adding a ``_defaults`` section with ``autowire`` and ``autoconfigure``.
.. code-block:: diff
- # app/config/services.yml
+ # config/services.yaml
services:
+ _defaults:
+ autowire: true
@@ -601,19 +601,19 @@ Start by updating the service ids to class names:
.. code-block:: diff
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
- app.github_notifier:
- - class: AppBundle\Service\GitHubNotifier
- + AppBundle\Service\GitHubNotifier:
+ - class: App\Service\GitHubNotifier
+ + App\Service\GitHubNotifier:
arguments:
- '@app.api_client_github'
- markdown_transformer:
- - class: AppBundle\Service\MarkdownTransformer
- + AppBundle\Service\MarkdownTransformer: ~
+ - class: App\Service\MarkdownTransformer
+ + App\Service\MarkdownTransformer: ~
# keep these ids because there are multiple instances per class
app.api_client_github:
@@ -643,14 +643,14 @@ to the new id. Create a new ``legacy_aliases.yml`` file:
# aliases so that the old service ids can still be accessed
# remove these if/when you are not fetching these directly
# from the container via $container->get()
- app.github_notifier: '@AppBundle\Service\GitHubNotifier'
- markdown_transformer: '@AppBundle\Service\MarkdownTransformer'
+ app.github_notifier: '@App\Service\GitHubNotifier'
+ markdown_transformer: '@App\Service\MarkdownTransformer'
-Then import this at the top of ``services.yml``:
+Then import this at the top of ``services.yaml``:
.. code-block:: diff
- # app/config/services.yml
+ # config/services.yaml
+ imports:
+ - { resource: legacy_aliases.yml }
@@ -666,7 +666,7 @@ Now you're ready to default all services to be private:
.. code-block:: diff
- # app/config/services.yml
+ # config/services.yaml
# ...
services:
@@ -684,7 +684,7 @@ instances of the same class), you may need to make those public:
.. code-block:: diff
- # app/config/services.yml
+ # config/services.yaml
# ...
services:
@@ -708,23 +708,23 @@ clean that up.
Step 4) Auto-registering Services
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-You're now ready to automatically register all services in ``src/AppBundle/``
+You're now ready to automatically register all services in ``src/``
(and/or any other directory/bundle you have):
.. code-block:: diff
- # app/config/services.yml
+ # config/services.yaml
services:
_defaults:
# ...
- + AppBundle\:
- + resource: '../../src/AppBundle/*'
- + exclude: '../../src/AppBundle/{Entity,Repository}'
+ + App\:
+ + resource: '../../src/*'
+ + exclude: '../../src/{Entity,Repository}'
+
- + AppBundle\Controller\:
- + resource: '../../src/AppBundle/Controller'
+ + App\Controller\:
+ + resource: '../../src/Controller'
+ tags: ['controller.service_arguments']
# ...
@@ -738,14 +738,14 @@ same class:
.. code-block:: diff
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
+ # alias ApiClient to one of our services below
+ # app.api_client_github will be used to autowire ApiClient type-hints
- + AppBundle\Service\ApiClient: '@app.api_client_github'
+ + App\Service\ApiClient: '@app.api_client_github'
app.api_client_github:
# ...
@@ -785,7 +785,7 @@ these directly from the container, you can remove the ``public: true`` flag:
.. code-block:: diff
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
@@ -797,7 +797,7 @@ these directly from the container, you can remove the ``public: true`` flag:
# ...
- public: true
-Finally, you can optionally remove any services from ``services.yml`` whose arguments
+Finally, you can optionally remove any services from ``services.yaml`` whose arguments
can be autowired. The final configuration looks like this:
.. code-block:: yaml
@@ -808,31 +808,31 @@ can be autowired. The final configuration looks like this:
autoconfigure: true
public: false
- AppBundle\:
- resource: '../../src/AppBundle/*'
- exclude: '../../src/AppBundle/{Entity,Repository}'
+ App\:
+ resource: '../../src/*'
+ exclude: '../../src/{Entity,Repository}'
- AppBundle\Controller\:
- resource: '../../src/AppBundle/Controller'
+ App\Controller\:
+ resource: '../../src/Controller'
tags: ['controller.service_arguments']
- AppBundle\Service\GitHubNotifier:
+ App\Service\GitHubNotifier:
# this could be deleted, or I can keep being explicit
arguments:
- '@app.api_client_github'
# alias ApiClient to one of our services below
# app.api_client_github will be used to autowire ApiClient type-hints
- AppBundle\Service\ApiClient: '@app.api_client_github'
+ App\Service\ApiClient: '@app.api_client_github'
# keep these ids because there are multiple instances per class
app.api_client_github:
- class: AppBundle\Service\ApiClient
+ class: App\Service\ApiClient
arguments:
- 'https://api.github.com'
app.api_client_sl_connect:
- class: AppBundle\Service\ApiClient
+ class: App\Service\ApiClient
arguments:
- 'https://connect.sensiolabs.com/api'
diff --git a/service_container/alias_private.rst b/service_container/alias_private.rst
index ce84a756b92..b6bd077fa30 100644
--- a/service_container/alias_private.rst
+++ b/service_container/alias_private.rst
@@ -23,7 +23,7 @@ And in this case, those services do *not* need to be public.
So unless you *specifically* need to access a service directly from the container
via ``$container->get()``, the best-practice is to make your services *private*.
-In fact, the :ref:`default services.yml configuration ` configures
+In fact, the :ref:`default services.yaml configuration ` configures
all services to be private by default.
You can also control the ``public`` option on a service-by-service basis:
@@ -35,7 +35,7 @@ You can also control the ``public`` option on a service-by-service basis:
services:
# ...
- AppBundle\Service\Foo:
+ App\Service\Foo:
public: false
.. code-block:: xml
@@ -46,13 +46,13 @@ You can also control the ``public`` option on a service-by-service basis:
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
.. code-block:: php
- use AppBundle\Service\Foo;
+ use App\Service\Foo;
$container->register(Foo::class)
->setPublic(false);
@@ -68,7 +68,7 @@ not have run on that page.
Now that the service is private, you *should not* fetch the service directly
from the container::
- use AppBundle\Service\Foo;
+ use App\Service\Foo;
$container->get(Foo::class);
@@ -100,11 +100,11 @@ services.
services:
# ...
- AppBundle\Mail\PhpMailer:
+ App\Mail\PhpMailer:
public: false
app.mailer:
- alias: AppBundle\Mail\PhpMailer
+ alias: App\Mail\PhpMailer
public: true
.. code-block:: xml
@@ -116,15 +116,15 @@ services.
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
-
+
.. code-block:: php
- use AppBundle\Mail\PhpMailer;
+ use App\Mail\PhpMailer;
$container->register(PhpMailer::class)
->setPublic(false);
@@ -144,7 +144,7 @@ This means that when using the container directly, you can access the
services:
# ...
- app.mailer: '@AppBundle\Mail\PhpMailer'
+ app.mailer: '@App\Mail\PhpMailer'
Deprecating Services
--------------------
@@ -156,7 +156,7 @@ or you decided not to maintain it anymore), you can deprecate its definition:
.. code-block:: yaml
- AppBundle\Service\OldService:
+ App\Service\OldService:
deprecated: The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.
.. code-block:: xml
@@ -167,7 +167,7 @@ or you decided not to maintain it anymore), you can deprecate its definition:
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
The "%service_id%" service is deprecated since 2.8 and will be removed in 3.0.
@@ -175,7 +175,7 @@ or you decided not to maintain it anymore), you can deprecate its definition:
.. code-block:: php
- use AppBundle\Service\OldService;
+ use App\Service\OldService;
$container
->register(OldService::class)
diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst
index ba38a79adab..d6860f78d62 100644
--- a/service_container/autowiring.rst
+++ b/service_container/autowiring.rst
@@ -24,7 +24,7 @@ the alphabet.
Start by creating a ROT13 transformer class::
- namespace AppBundle\Util;
+ namespace App\Util;
class Rot13Transformer
{
@@ -36,9 +36,9 @@ Start by creating a ROT13 transformer class::
And now a Twitter client using this transformer::
- namespace AppBundle\Service;
+ namespace App\Service;
- use AppBundle\Util\Rot13Transformer;
+ use App\Util\Rot13Transformer;
class TwitterClient
{
@@ -57,7 +57,7 @@ And now a Twitter client using this transformer::
}
}
-If you're using the :ref:`default services.yml configuration `,
+If you're using the :ref:`default services.yaml configuration `,
**both classes are automatically registered as services and configured to be autowired**.
This means you can use them immediately without *any* configuration.
@@ -76,13 +76,13 @@ both services. Also, to keep things simple, configure ``TwitterClient`` to be a
public: false
# ...
- AppBundle\Service\TwitterClient:
+ App\Service\TwitterClient:
# redundant thanks to _defaults, but value is overridable on each service
autowire: true
# not required, will help in our example
public: true
- AppBundle\Util\Rot13Transformer:
+ App\Util\Rot13Transformer:
autowire: true
.. code-block:: xml
@@ -96,16 +96,16 @@ both services. Also, to keep things simple, configure ``TwitterClient`` to be a
-
+
-
+
.. code-block:: php
- use AppBundle\Service\TwitterClient;
- use AppBundle\Util\Rot13Transformer;
+ use App\Service\TwitterClient;
+ use App\Util\Rot13Transformer;
// ...
@@ -119,9 +119,9 @@ both services. Also, to keep things simple, configure ``TwitterClient`` to be a
Now, you can use the ``TwitterClient`` service immediately in a controller::
- namespace AppBundle\Controller;
+ namespace App\Controller;
- use AppBundle\Service\TwitterClient;
+ use App\Service\TwitterClient;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
@@ -152,7 +152,7 @@ Autowiring Logic Explained
Autowiring works by reading the ``Rot13Transformer`` *type-hint* in ``TwitterClient``::
// ...
- use AppBundle\Util\Rot13Transformer;
+ use App\Util\Rot13Transformer;
class TwitterClient
{
@@ -218,13 +218,13 @@ adding a service alias:
# the id is not a class, so it won't be used for autowiring
app.rot13.transformer:
- class: AppBundle\Util\Rot13Transformer
+ class: App\Util\Rot13Transformer
# ...
# but this fixes it!
# the ``app.rot13.transformer`` service will be injected when
- # an ``AppBundle\Util\Rot13Transformer`` type-hint is detected
- AppBundle\Util\Rot13Transformer: '@app.rot13.transformer'
+ # an ``App\Util\Rot13Transformer`` type-hint is detected
+ App\Util\Rot13Transformer: '@app.rot13.transformer'
.. code-block:: xml
@@ -236,14 +236,14 @@ adding a service alias:
-
-
+
+
.. code-block:: php
- use AppBundle\Util\Rot13Transformer;
+ use App\Util\Rot13Transformer;
// ...
@@ -251,7 +251,7 @@ adding a service alias:
->setPublic(false);
$container->setAlias(Rot13Transformer::class, 'app.rot13.transformer');
-This creates a service "alias", whose id is ``AppBundle\Util\Rot13Transformer``.
+This creates a service "alias", whose id is ``App\Util\Rot13Transformer``.
Thanks to this, autowiring sees this and uses it whenever the ``Rot13Transformer``
class is type-hinted.
@@ -273,7 +273,7 @@ objects.
To follow this best practice, suppose you decide to create a ``TransformerInterface``::
- namespace AppBundle\Util;
+ namespace App\Util;
interface TransformerInterface
{
@@ -300,7 +300,7 @@ Now that you have an interface, you should use this as your type-hint::
// ...
}
-But now, the type-hint (``AppBundle\Util\TransformerInterface``) no longer matches
+But now, the type-hint (``App\Util\TransformerInterface``) no longer matches
the id of the service (``AppBundle\Util\Rot13Transformer``). This means that the
argument can no longer be autowired (actually, it
:ref:`will work now, but not in Symfony 4.0 `).
@@ -314,11 +314,11 @@ To fix that, add an :ref:`alias `:
services:
# ...
- AppBundle\Util\Rot13Transformer: ~
+ App\Util\Rot13Transformer: ~
- # the ``AppBundle\Util\Rot13Transformer`` service will be injected when
- # an ``AppBundle\Util\TransformerInterface`` type-hint is detected
- AppBundle\Util\TransformerInterface: '@AppBundle\Util\Rot13Transformer'
+ # the ``App\Util\Rot13Transformer`` service will be injected when
+ # an ``App\Util\TransformerInterface`` type-hint is detected
+ App\Util\TransformerInterface: '@App\Util\Rot13Transformer'
.. code-block:: xml
@@ -329,22 +329,22 @@ To fix that, add an :ref:`alias `:
-
+
-
+
.. code-block:: php
- use AppBundle\Util\Rot13Transformer;
- use AppBundle\Util\TransformerInterface;
+ use App\Util\Rot13Transformer;
+ use App\Util\TransformerInterface;
// ...
$container->autowire(Rot13Transformer::class);
$container->setAlias(TransformerInterface::class, Rot13Transformer::class);
-Thanks to the ``AppBundle\Util\TransformerInterface`` alias, the autowiring subsystem
+Thanks to the ``App\Util\TransformerInterface`` alias, the autowiring subsystem
knows that the ``AppBundle\Util\Rot13Transformer`` service should be injected when
dealing with the ``TransformerInterface``.
@@ -354,7 +354,7 @@ Dealing with Multiple Implementations of the Same Type
Suppose you create a second class - ``UppercaseTransformer`` that implements
``TransformerInterface``::
- namespace AppBundle\Util;
+ namespace App\Util;
class UppercaseTransformer implements TransformerInterface
{
@@ -379,20 +379,20 @@ that alias:
services:
# ...
- AppBundle\Util\Rot13Transformer: ~
- AppBundle\Util\UppercaseTransformer: ~
+ App\Util\Rot13Transformer: ~
+ App\Util\UppercaseTransformer: ~
- # the ``AppBundle\Util\Rot13Transformer`` service will be injected when
- # a ``AppBundle\Util\TransformerInterface`` type-hint is detected
- AppBundle\Util\TransformerInterface: '@AppBundle\Util\Rot13Transformer'
+ # the ``App\Util\Rot13Transformer`` service will be injected when
+ # a ``App\Util\TransformerInterface`` type-hint is detected
+ App\Util\TransformerInterface: '@App\Util\Rot13Transformer'
- AppBundle\Service\TwitterClient:
+ App\Service\TwitterClient:
# the Rot13Transformer will be passed as the $transformer argument
autowire: true
# If you wanted to choose the non-default service, wire it manually
# arguments:
- # $transformer: '@AppBundle\Util\UppercaseTransformer'
+ # $transformer: '@App\Util\UppercaseTransformer'
# ...
.. code-block:: xml
@@ -404,23 +404,23 @@ that alias:
-
-
+
+
-
+
-
.. code-block:: php
- use AppBundle\Util\Rot13Transformer;
- use AppBundle\Util\UppercaseTransformer;
- use AppBundle\Util\TransformerInterface;
- use AppBundle\Service\TwitterClient;
+ use App\Util\Rot13Transformer;
+ use App\Util\UppercaseTransformer;
+ use App\Util\TransformerInterface;
+ use App\Service\TwitterClient;
// ...
$container->autowire(Rot13Transformer::class);
@@ -430,7 +430,7 @@ that alias:
//->setArgument('$transformer', new Reference(UppercaseTransformer::class))
;
-Thanks to the ``AppBundle\Util\TransformerInterface`` alias, any argument type-hinted
+Thanks to the ``App\Util\TransformerInterface`` alias, any argument type-hinted
with this interface will be passed the ``AppBundle\Util\Rot13Transformer`` service.
But, you can also manually wire the *other* service by specifying the argument
under the arguments key.
@@ -458,7 +458,7 @@ When autowiring is enabled for a service, you can *also* configure the container
to call methods on your class when it's instantiated. For example, suppose you want
to inject the ``logger`` service, and decide to use setter-injection::
- namespace AppBundle\Util;
+ namespace App\Util;
class Rot13Transformer
{
diff --git a/service_container/calls.rst b/service_container/calls.rst
index 85fc04571d3..6807f30f9fe 100644
--- a/service_container/calls.rst
+++ b/service_container/calls.rst
@@ -13,7 +13,7 @@ Usually, you'll want to inject your dependencies via the constructor. But someti
especially if a dependency is optional, you may want to use "setter injection". For
example::
- namespace AppBundle\Service;
+ namespace App\Service;
use Psr\Log\LoggerInterface;
@@ -35,9 +35,9 @@ To configure the container to call the ``setLogger`` method, use the ``calls`` k
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
- AppBundle\Service\MessageGenerator:
+ App\Service\MessageGenerator:
# ...
calls:
- method: setLogger
@@ -46,7 +46,7 @@ To configure the container to call the ``setLogger`` method, use the ``calls`` k
.. code-block:: xml
-
+
-
+
@@ -65,8 +65,8 @@ To configure the container to call the ``setLogger`` method, use the ``calls`` k
.. code-block:: php
- // app/config/services.php
- use AppBundle\Service\MessageGenerator;
+ // config/services.php
+ use App\Service\MessageGenerator;
use Symfony\Component\DependencyInjection\Reference;
$container->register(MessageGenerator::class)
diff --git a/service_container/compiler_passes.rst b/service_container/compiler_passes.rst
index 55ac01b5b8c..c8a55ece04f 100644
--- a/service_container/compiler_passes.rst
+++ b/service_container/compiler_passes.rst
@@ -14,12 +14,12 @@ When using :ref:`separate compiler passes `,
+you're using the :ref:`default services.yaml configuration `,
all the classes are already loaded as services. All you need to do is specify the
``configurator``:
@@ -125,25 +125,25 @@ all the classes are already loaded as services. All you need to do is specify th
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
- # Registers all 4 classes as services, including AppBundle\Mail\EmailConfigurator
- AppBundle\:
- resource: '../../src/AppBundle/*'
+ # Registers all 4 classes as services, including App\Mail\EmailConfigurator
+ App\:
+ resource: '../../src/*'
# ...
# override the services to set the configurator
- AppBundle\Mail\NewsletterManager:
- configurator: 'AppBundle\Mail\EmailConfigurator:configure'
+ App\Mail\NewsletterManager:
+ configurator: 'App\Mail\EmailConfigurator:configure'
- AppBundle\Mail\GreetingCardManager:
- configurator: 'AppBundle\Mail\EmailConfigurator:configure'
+ App\Mail\GreetingCardManager:
+ configurator: 'App\Mail\EmailConfigurator:configure'
.. code-block:: xml
-
+
-
+
-
-
+
+
-
-
+
+
.. code-block:: php
- // app/config/services.php
- use AppBundle\Mail\GreetingCardManager;
- use AppBundle\Mail\NewsletterManager;
+ // config/services.php
+ use App\Mail\GreetingCardManager;
+ use App\Mail\NewsletterManager;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
@@ -176,7 +176,7 @@ all the classes are already loaded as services. All you need to do is specify th
$definition->setAutowired(true);
- $this->registerClasses($definition, 'AppBundle\\', '../../src/AppBundle/*');
+ $this->registerClasses($definition, 'App\\', '../../src/*');
$container->getDefinition(NewsletterManager::class)
->setConfigurator(array(new Reference(EmailConfigurator::class), 'configure'));
@@ -196,10 +196,10 @@ all the classes are already loaded as services. All you need to do is specify th
app.newsletter_manager:
# new syntax
- configurator: 'AppBundle\Mail\EmailConfigurator:configure'
+ configurator: 'App\Mail\EmailConfigurator:configure'
# old syntax
- configurator: ['@AppBundle\Mail\EmailConfigurator', configure]
+ configurator: ['@App\Mail\EmailConfigurator', configure]
-That's it! When requesting the ``AppBundle\Mail\NewsletterManager`` or
+That's it! When requesting the ``App\Mail\NewsletterManager`` or
``AppBundle\Mail\GreetingCardManager`` service, the created instance will first be
passed to the ``EmailConfigurator::configure()`` method.
diff --git a/service_container/debug.rst b/service_container/debug.rst
index f235b38392e..0838cb5ed7f 100644
--- a/service_container/debug.rst
+++ b/service_container/debug.rst
@@ -35,10 +35,10 @@ its id:
.. code-block:: terminal
- $ php bin/console debug:container 'AppBundle\Service\Mailer'
+ $ php bin/console debug:container 'App\Service\Mailer'
# to show the service arguments:
- $ php bin/console debug:container 'AppBundle\Service\Mailer' --show-arguments
+ $ php bin/console debug:container 'App\Service\Mailer' --show-arguments
.. versionadded:: 3.3
The ``--show-arguments`` option was introduced in Symfony 3.3.
diff --git a/service_container/definitions.rst b/service_container/definitions.rst
index 8a159eeb3a0..af4b90fc04c 100644
--- a/service_container/definitions.rst
+++ b/service_container/definitions.rst
@@ -32,14 +32,14 @@ There are some helpful methods for working with the service definitions::
$definition = $container->findDefinition('app.user_config_manager');
// add a new "app.number_generator" definition
- $definition = new Definition(\AppBundle\NumberGenerator::class);
+ $definition = new Definition(\App\NumberGenerator::class);
$container->setDefinition('app.number_generator', $definition);
// shortcut for the previous method
- $container->register('app.number_generator', \AppBundle\NumberGenerator::class);
+ $container->register('app.number_generator', \App\NumberGenerator::class);
// or create a service whose id matches its class
- $container->register(\AppBundle\NumberGenerator::class);
+ $container->register(\App\NumberGenerator::class);
Working with a Definition
-------------------------
@@ -57,8 +57,8 @@ Class
The first optional argument of the ``Definition`` class is the fully qualified
class name of the object returned when the service is fetched from the container::
- use AppBundle\Config\UserConfigManager;
- use AppBundle\Config\CustomConfigManager;
+ use App\Config\UserConfigManager;
+ use App\Config\CustomConfigManager;
use Symfony\Component\DependencyInjection\Definition;
$definition = new Definition(UserConfigManager::class);
@@ -76,7 +76,7 @@ The second optional argument of the ``Definition`` class is an array with the
arguments passed to the constructor of the object returned when the service is
fetched from the container::
- use AppBundle\Config\DoctrineConfigManager;
+ use App\Config\DoctrineConfigManager;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
diff --git a/service_container/expression_language.rst b/service_container/expression_language.rst
index de887ebf504..83cd112712e 100644
--- a/service_container/expression_language.rst
+++ b/service_container/expression_language.rst
@@ -21,18 +21,18 @@ to another service: ``AppBundle\Mailer``. One way to do this is with an expressi
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
- AppBundle\Mail\MailerConfiguration: ~
+ App\Mail\MailerConfiguration: ~
- AppBundle\Mailer:
- arguments: ["@=service('AppBundle\\\\Mail\\\\MailerConfiguration').getMailerMethod()"]
+ App\Mailer:
+ arguments: ["@=service('App\\\\Mail\\\\MailerConfiguration').getMailerMethod()"]
.. code-block:: xml
-
+
-
+
-
- service('AppBundle\Mail\MailerConfiguration').getMailerMethod()
+
+ service('App\Mail\MailerConfiguration').getMailerMethod()
.. code-block:: php
- // app/config/services.php
- use AppBundle\Mail\MailerConfiguration;
- use AppBundle\Mailer;
+ // config/services.php
+ use App\Mail\MailerConfiguration;
+ use App\Mailer;
use Symfony\Component\ExpressionLanguage\Expression;
$container->autowire(MailerConfiguration::class);
$container->autowire(Mailer::class)
- ->addArgument(new Expression('service("AppBundle\Mail\MailerConfiguration").getMailerMethod()'));
+ ->addArgument(new Expression('service("App\Mail\MailerConfiguration").getMailerMethod()'));
To learn more about the expression language syntax, see :doc:`/components/expression_language/syntax`.
@@ -79,7 +79,7 @@ via a ``container`` variable. Here's another example:
.. code-block:: yaml
services:
- AppBundle\Mailer:
+ App\Mailer:
arguments: ["@=container.hasParameter('some_param') ? parameter('some_param') : 'default_value'"]
.. code-block:: xml
@@ -91,7 +91,7 @@ via a ``container`` variable. Here's another example:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
container.hasParameter('some_param') ? parameter('some_param') : 'default_value'
@@ -99,7 +99,7 @@ via a ``container`` variable. Here's another example:
.. code-block:: php
- use AppBundle\Mailer;
+ use App\Mailer;
use Symfony\Component\ExpressionLanguage\Expression;
$container->autowire(Mailer::class)
diff --git a/service_container/factories.rst b/service_container/factories.rst
index 316d1cb7d44..21cf8875255 100644
--- a/service_container/factories.rst
+++ b/service_container/factories.rst
@@ -35,17 +35,17 @@ configure the service container to use the
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
- AppBundle\Email\NewsletterManager:
+ App\Email\NewsletterManager:
# call the static method
- factory: ['AppBundle\Email\NewsletterManagerStaticFactory', createNewsletterManager]
+ factory: ['App\Email\NewsletterManagerStaticFactory', createNewsletterManager]
.. code-block:: xml
-
+
-
+
-
+
.. code-block:: php
- // app/config/services.php
+ // config/services.php
- use AppBundle\Email\NewsletterManager;
- use AppBundle\NumberGenerator;
- use AppBundle\Email\NewsletterManagerStaticFactory;
+ use App\Email\NewsletterManager;
+ use App\NumberGenerator;
+ use App\Email\NewsletterManagerStaticFactory;
// ...
$container->register(NumberGenerator::class)
@@ -93,20 +93,20 @@ Configuration of the service container then looks like this:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
- AppBundle\Email\NewsletterManagerFactory: ~
+ App\Email\NewsletterManagerFactory: ~
- AppBundle\Email\NewsletterManager:
+ App\Email\NewsletterManager:
# call a method on the specified factory service
- factory: 'AppBundle\Email\NewsletterManagerFactory:createNewsletterManager'
+ factory: 'App\Email\NewsletterManagerFactory:createNewsletterManager'
.. code-block:: xml
-
+
-
+
-
+
-
@@ -128,10 +128,10 @@ Configuration of the service container then looks like this:
.. code-block:: php
- // app/config/services.php
+ // config/services.php
- use AppBundle\Email\NewsletterManager;
- use AppBundle\Email\NewsletterManagerFactory;
+ use App\Email\NewsletterManager;
+ use App\Email\NewsletterManagerFactory;
// ...
$container->register(NewsletterManagerFactory::class);
@@ -150,14 +150,14 @@ Configuration of the service container then looks like this:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
app.newsletter_manager:
- class: AppBundle\Email\NewsletterManager
+ class: App\Email\NewsletterManager
# new syntax
- factory: 'AppBundle\Email\NewsletterManagerFactory:createNewsletterManager'
+ factory: 'App\Email\NewsletterManagerFactory:createNewsletterManager'
# old syntax
- factory: ['@AppBundle\Email\NewsletterManagerFactory', createNewsletterManager]
+ factory: ['@App\Email\NewsletterManagerFactory', createNewsletterManager]
.. _factories-passing-arguments-factory-method:
@@ -177,18 +177,18 @@ example takes the ``templating`` service as an argument:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
# ...
- AppBundle\Email\NewsletterManager:
- factory: 'AppBundle\Email\NewsletterManagerFactory:createNewsletterManager'
+ App\Email\NewsletterManager:
+ factory: 'App\Email\NewsletterManagerFactory:createNewsletterManager'
arguments: ['@templating']
.. code-block:: xml
-
+
-
-
+
+
@@ -208,10 +208,10 @@ example takes the ``templating`` service as an argument:
.. code-block:: php
- // app/config/services.php
+ // config/services.php
- use AppBundle\Email\NewsletterManager;
- use AppBundle\Email\NewsletterManagerFactory;
+ use App\Email\NewsletterManager;
+ use App\Email\NewsletterManagerFactory;
use Symfony\Component\DependencyInjection\Reference;
// ...
diff --git a/service_container/import.rst b/service_container/import.rst
index 8c98b43aa84..76647d99c43 100644
--- a/service_container/import.rst
+++ b/service_container/import.rst
@@ -32,7 +32,7 @@ methods.
Importing Configuration with ``imports``
----------------------------------------
-By default, service configuration lives in ``app/config/services.yml``. But if that
+By default, service configuration lives in ``config/services.yaml``. But if that
file becomes large, you're free to organize into multiple files. For suppose you
decided to move some configuration to a new file:
@@ -78,13 +78,13 @@ To import this file, use the ``imports`` key from a file that *is* loaded:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
imports:
- { resource: services/mailer.yml }
.. code-block:: xml
-
+
import('services/mailer.php');
The ``resource`` location, for files, is either a relative path from the
diff --git a/service_container/injection_types.rst b/service_container/injection_types.rst
index d2afc93b044..e5c7fe78dbf 100644
--- a/service_container/injection_types.rst
+++ b/service_container/injection_types.rst
@@ -19,7 +19,7 @@ The most common way to inject dependencies is via a class's constructor.
To do this you need to add an argument to the constructor signature to accept
the dependency::
- namespace AppBundle\Mail;
+ namespace App\Mail;
// ...
class NewsletterManager
@@ -44,7 +44,7 @@ service container configuration:
services:
# ...
- AppBundle\Mail\NewsletterManager:
+ App\Mail\NewsletterManager:
arguments: ['@mailer']
.. code-block:: xml
@@ -58,7 +58,7 @@ service container configuration:
-
+
@@ -66,7 +66,7 @@ service container configuration:
.. code-block:: php
- use AppBundle\Mail\NewsletterManager;
+ use App\Mail\NewsletterManager;
use Symfony\Component\DependencyInjection\Reference;
// ...
@@ -124,7 +124,7 @@ that accepts the dependency::
# ...
app.newsletter_manager:
- class: AppBundle\Mail\NewsletterManager
+ class: App\Mail\NewsletterManager
calls:
- [setMailer, ['@mailer']]
@@ -139,7 +139,7 @@ that accepts the dependency::
-
+
@@ -149,7 +149,7 @@ that accepts the dependency::
.. code-block:: php
- use AppBundle\Mail\NewsletterManager;
+ use App\Mail\NewsletterManager;
use Symfony\Component\DependencyInjection\Reference;
// ...
@@ -196,7 +196,7 @@ Another possibility is just setting public fields of the class directly::
# ...
app.newsletter_manager:
- class: AppBundle\Mail\NewsletterManager
+ class: App\Mail\NewsletterManager
properties:
mailer: '@mailer'
@@ -211,7 +211,7 @@ Another possibility is just setting public fields of the class directly::
-
+
@@ -219,7 +219,7 @@ Another possibility is just setting public fields of the class directly::
.. code-block:: php
- use AppBundle\Mail\NewsletterManager;
+ use App\Mail\NewsletterManager;
use Symfony\Component\DependencyInjection\Reference;
// ...
diff --git a/service_container/lazy_services.rst b/service_container/lazy_services.rst
index 2b0ab1ee960..e38377f6b36 100644
--- a/service_container/lazy_services.rst
+++ b/service_container/lazy_services.rst
@@ -52,7 +52,7 @@ You can mark the service as ``lazy`` by manipulating its definition:
.. code-block:: yaml
services:
- AppBundle\Twig\AppExtension:
+ App\Twig\AppExtension:
lazy: true
.. code-block:: xml
@@ -64,13 +64,13 @@ You can mark the service as ``lazy`` by manipulating its definition:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
.. code-block:: php
- use AppBundle\Twig\AppExtension;
+ use App\Twig\AppExtension;
$container->register(AppExtension::class)
->setLazy(true);
diff --git a/service_container/optional_dependencies.rst b/service_container/optional_dependencies.rst
index 3148bd30c47..bbd0e775745 100644
--- a/service_container/optional_dependencies.rst
+++ b/service_container/optional_dependencies.rst
@@ -15,7 +15,7 @@ if the service does not exist:
.. code-block:: xml
-
+
-
+
@@ -33,8 +33,8 @@ if the service does not exist:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Newsletter\NewsletterManager;
+ // config/services.php
+ use App\Newsletter\NewsletterManager;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -64,16 +64,16 @@ call if the service exists and remove the method call if it does not:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
app.newsletter_manager:
- class: AppBundle\Newsletter\NewsletterManager
+ class: App\Newsletter\NewsletterManager
calls:
- [setLogger, ['@?logger']]
.. code-block:: xml
-
+
-
+
@@ -95,8 +95,8 @@ call if the service exists and remove the method call if it does not:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Newsletter\NewsletterManager;
+ // config/services.php
+ use App\Newsletter\NewsletterManager;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerInterface;
diff --git a/service_container/parameters.rst b/service_container/parameters.rst
index 232449d79c9..aecb4294e51 100644
--- a/service_container/parameters.rst
+++ b/service_container/parameters.rst
@@ -54,7 +54,7 @@ and hidden with the service definition:
mailer.transport: sendmail
services:
- AppBundle\Service\Mailer:
+ App\Service\Mailer:
arguments: ['%mailer.transport%']
.. code-block:: xml
@@ -70,7 +70,7 @@ and hidden with the service definition:
-
+
%mailer.transport%
@@ -78,7 +78,7 @@ and hidden with the service definition:
.. code-block:: php
- use AppBundle\Mailer;
+ use App\Mailer;
$container->setParameter('mailer.transport', 'sendmail');
diff --git a/service_container/parent_services.rst b/service_container/parent_services.rst
index c41a35ebdf8..596423c8393 100644
--- a/service_container/parent_services.rst
+++ b/service_container/parent_services.rst
@@ -9,8 +9,8 @@ have related classes that share some of the same dependencies. For example,
you may have multiple repository classes which need the
``doctrine.orm.entity_manager`` service and an optional ``logger`` service::
- // src/AppBundle/Repository/BaseDoctrineRepository.php
- namespace AppBundle\Repository;
+ // src/Repository/BaseDoctrineRepository.php
+ namespace App\Repository;
// ...
abstract class BaseDoctrineRepository
@@ -33,10 +33,10 @@ you may have multiple repository classes which need the
Your child service classes may look like this::
- // src/AppBundle/Repository/DoctrineUserRepository.php
- namespace AppBundle\Repository;
+ // src/Repository/DoctrineUserRepository.php
+ namespace App\Repository;
- use AppBundle\Repository\BaseDoctrineRepository
+ use App\Repository\BaseDoctrineRepository
// ...
class DoctrineUserRepository extends BaseDoctrineRepository
@@ -44,10 +44,10 @@ Your child service classes may look like this::
// ...
}
- // src/AppBundle/Repository/DoctrinePostRepository.php
- namespace AppBundle\Repository;
+ // src/Repository/DoctrinePostRepository.php
+ namespace App\Repository;
- use AppBundle\Repository\BaseDoctrineRepository
+ use App\Repository\BaseDoctrineRepository
// ...
class DoctrinePostRepository extends BaseDoctrineRepository
@@ -64,18 +64,18 @@ duplicated service definitions:
.. code-block:: yaml
services:
- AppBundle\Repository\BaseDoctrineRepository:
+ App\Repository\BaseDoctrineRepository:
abstract: true
arguments: ['@doctrine.orm.entity_manager']
calls:
- [setLogger, ['@logger']]
- AppBundle\Repository\DoctrineUserRepository:
- # extend the AppBundle\Repository\BaseDoctrineRepository service
- parent: AppBundle\Repository\BaseDoctrineRepository
+ App\Repository\DoctrineUserRepository:
+ # extend the App\Repository\BaseDoctrineRepository service
+ parent: App\Repository\BaseDoctrineRepository
- AppBundle\Repository\DoctrinePostRepository:
- parent: AppBundle\Repository\BaseDoctrineRepository
+ App\Repository\DoctrinePostRepository:
+ parent: App\Repository\BaseDoctrineRepository
# ...
@@ -88,7 +88,7 @@ duplicated service definitions:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -96,13 +96,13 @@ duplicated service definitions:
-
-
+
-
@@ -111,9 +111,9 @@ duplicated service definitions:
.. code-block:: php
- use AppBundle\Repository\DoctrineUserRepository;
- use AppBundle\Repository\DoctrinePostRepository;
- use AppBundle\Repository\BaseDoctrineRepository;
+ use App\Repository\DoctrineUserRepository;
+ use App\Repository\DoctrinePostRepository;
+ use App\Repository\BaseDoctrineRepository;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Reference;
@@ -123,7 +123,7 @@ duplicated service definitions:
->addMethodCall('setLogger', array(new Reference('logger')))
;
- // extend the AppBundle\Repository\BaseDoctrineRepository service
+ // extend the App\Repository\BaseDoctrineRepository service
$definition = new ChildDefinition(BaseDoctrineRepository::class);
$definition->setClass(DoctrineUserRepository::class);
$container->setDefinition(DoctrineUserRepository::class, $definition);
@@ -169,8 +169,8 @@ in the child class:
services:
# ...
- AppBundle\Repository\DoctrineUserRepository:
- parent: AppBundle\Repository\BaseDoctrineRepository
+ App\Repository\DoctrineUserRepository:
+ parent: App\Repository\BaseDoctrineRepository
# overrides the public setting of the parent service
public: false
@@ -179,8 +179,8 @@ in the child class:
# argument list
arguments: ['@app.username_checker']
- AppBundle\Repository\DoctrinePostRepository:
- parent: AppBundle\Repository\BaseDoctrineRepository
+ App\Repository\DoctrinePostRepository:
+ parent: App\Repository\BaseDoctrineRepository
# overrides the first argument (using the special index_N key)
arguments:
@@ -198,8 +198,8 @@ in the child class:
-
@@ -220,9 +220,9 @@ in the child class:
.. code-block:: php
- use AppBundle\Repository\DoctrineUserRepository;
- use AppBundle\Repository\DoctrinePostRepository;
- use AppBundle\Repository\BaseDoctrineRepository;
+ use App\Repository\DoctrineUserRepository;
+ use App\Repository\DoctrinePostRepository;
+ use App\Repository\BaseDoctrineRepository;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Reference;
// ...
diff --git a/service_container/request.rst b/service_container/request.rst
index 5b4f4af738c..2f68b722eb7 100644
--- a/service_container/request.rst
+++ b/service_container/request.rst
@@ -11,7 +11,7 @@ add it as an argument to the methods that need the request or inject the
:method:`Symfony\\Component\\HttpFoundation\\RequestStack::getCurrentRequest`
method::
- namespace AppBundle\Newsletter;
+ namespace App\Newsletter;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -34,7 +34,7 @@ method::
}
Now, just inject the ``request_stack``, which behaves like any normal service.
-If you're using the :ref:`default services.yml configuration `,
+If you're using the :ref:`default services.yaml configuration `,
this will happen automatically via autowiring.
.. tip::
diff --git a/service_container/service_decoration.rst b/service_container/service_decoration.rst
index 6c1529427bc..289a70ac70d 100644
--- a/service_container/service_decoration.rst
+++ b/service_container/service_decoration.rst
@@ -13,12 +13,12 @@ the original service is lost:
services:
app.mailer:
- class: AppBundle\Mailer
+ class: App\Mailer
# this replaces the old app.mailer definition with the new one, the
# old definition is lost
app.mailer:
- class: AppBundle\DecoratingMailer
+ class: App\DecoratingMailer
.. code-block:: xml
@@ -28,18 +28,18 @@ the original service is lost:
xsd:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
-
+
.. code-block:: php
- use AppBundle\Mailer;
- use AppBundle\DecoratingMailer;
+ use App\Mailer;
+ use App\DecoratingMailer;
$container->register('app.mailer', Mailer::class);
@@ -57,10 +57,10 @@ that you can reference it:
services:
app.mailer:
- class: AppBundle\Mailer
+ class: App\Mailer
app.decorating_mailer:
- class: AppBundle\DecoratingMailer
+ class: App\DecoratingMailer
# overrides the app.mailer service
# but that service is still available as app.decorating_mailer.inner
decorates: app.mailer
@@ -79,10 +79,10 @@ that you can reference it:
xsd:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
@@ -94,8 +94,8 @@ that you can reference it:
.. code-block:: php
- use AppBundle\DecoratingMailer;
- use AppBundle\Mailer;
+ use App\DecoratingMailer;
+ use App\Mailer;
use Symfony\Component\DependencyInjection\Reference;
$container->register('app.mailer', Mailer::class);
@@ -145,7 +145,7 @@ replaces the ``app.mailer`` service. The old ``app.mailer`` service is renamed t
register('app.decorating_mailer', DecoratingMailer::class)
diff --git a/service_container/service_locators.rst b/service_container/service_locators.rst
index 5471eef80a5..83aebb5f9da 100644
--- a/service_container/service_locators.rst
+++ b/service_container/service_locators.rst
@@ -14,7 +14,7 @@ A real-world example are applications that implement the `Command pattern`_
using a CommandBus to map command handlers by Command class names and use them
to handle their respective command when it is asked for::
- // src/AppBundle/CommandBus.php
+ // src/CommandBus.php
namespace AppBundle;
// ...
@@ -91,19 +91,19 @@ option to include as many services as needed to it and add the
.. code-block:: yaml
- // app/config/services.yml
+ // config/services.yaml
services:
app.command_handler_locator:
class: Symfony\Component\DependencyInjection\ServiceLocator
tags: ['container.service_locator']
arguments:
-
- AppBundle\FooCommand: '@app.command_handler.foo'
- AppBundle\BarCommand: '@app.command_handler.bar'
+ App\FooCommand: '@app.command_handler.foo'
+ App\BarCommand: '@app.command_handler.bar'
.. code-block:: xml
-
+
-
-
+
+
@@ -124,7 +124,7 @@ option to include as many services as needed to it and add the
.. code-block:: php
- // app/config/services.php
+ // config/services.php
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\DependencyInjection\Reference;
@@ -134,8 +134,8 @@ option to include as many services as needed to it and add the
->register('app.command_handler_locator', ServiceLocator::class)
->addTag('container.service_locator')
->setArguments(array(array(
- 'AppBundle\FooCommand' => new Reference('app.command_handler.foo'),
- 'AppBundle\BarCommand' => new Reference('app.command_handler.bar'),
+ 'App\FooCommand' => new Reference('app.command_handler.foo'),
+ 'App\BarCommand' => new Reference('app.command_handler.bar'),
)))
;
@@ -150,14 +150,14 @@ Now you can use the service locator injecting it in any other service:
.. code-block:: yaml
- // app/config/services.yml
+ // config/services.yaml
services:
- AppBundle\CommandBus:
+ App\CommandBus:
arguments: ['@app.command_handler_locator']
.. code-block:: xml
-
+
-
+
@@ -174,8 +174,8 @@ Now you can use the service locator injecting it in any other service:
.. code-block:: php
- // app/config/services.php
- use AppBundle\CommandBus;
+ // config/services.php
+ use App\CommandBus;
use Symfony\Component\DependencyInjection\Reference;
$container
diff --git a/service_container/shared.rst b/service_container/shared.rst
index f174868aef3..ad36a924719 100644
--- a/service_container/shared.rst
+++ b/service_container/shared.rst
@@ -16,26 +16,26 @@ in your service definition:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
- AppBundle\SomeNonSharedService:
+ App\SomeNonSharedService:
shared: false
# ...
.. code-block:: xml
-
+
-
+
.. code-block:: php
- // app/config/services.php
- use AppBundle\SomeNonSharedService;
+ // config/services.php
+ use App\SomeNonSharedService;
$container->register(SomeNonSharedService::class)
->setShared(false);
-Now, whenever you request an the ``AppBundle\SomeNonSharedService`` from the container,
+Now, whenever you request an the ``App\SomeNonSharedService`` from the container,
you will be passed a new instance.
diff --git a/service_container/tags.rst b/service_container/tags.rst
index bf194463cab..fd0276fc818 100644
--- a/service_container/tags.rst
+++ b/service_container/tags.rst
@@ -14,15 +14,15 @@ to be used for a specific purpose. Take the following example:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
- AppBundle\Twig\AppExtension:
+ App\Twig\AppExtension:
public: false
tags: [twig.extension]
.. code-block:: xml
-
+
-
+
@@ -38,8 +38,8 @@ to be used for a specific purpose. Take the following example:
.. code-block:: php
- // app/config/services.php
- use AppBundle\Twig\AppExtension;
+ // config/services.php
+ use App\Twig\AppExtension;
$container->register('app.twig_extension', AppExtension::class)
->setPublic(false)
@@ -76,8 +76,8 @@ that it implements ``Twig_ExtensionInterface``) and adds the tag for you.
interface, call the :method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::registerForAutoconfiguration`
method in an :doc:`extension ` or from your kernel::
- // app/AppKernel.php
- class AppKernel extends Kernel
+ // src/Kernel.php
+ class Kernel extends Kernel
{
// ...
@@ -105,8 +105,8 @@ ways of transporting the message until one succeeds.
To begin with, define the ``TransportChain`` class::
- // src/AppBundle/Mail/TransportChain.php
- namespace AppBundle\Mail;
+ // src/Mail/TransportChain.php
+ namespace App\Mail;
class TransportChain
{
@@ -130,7 +130,7 @@ Then, define the chain as a service:
.. code-block:: yaml
services:
- AppBundle\Mail\TransportChain: ~
+ App\Mail\TransportChain: ~
.. code-block:: xml
@@ -141,13 +141,13 @@ Then, define the chain as a service:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
.. code-block:: php
- use AppBundle\Mail\TransportChain;
+ use App\Mail\TransportChain;
$container->autowire(TransportChain::class);
@@ -212,13 +212,13 @@ Create a Compiler Pass
You can now use a :ref:`compiler pass ` to ask the
container for any services with the ``app.mail_transport`` tag::
- // src/AppBundle/DependencyInjection/Compiler/MailTransportPass.php
- namespace AppBundle\DependencyInjection\Compiler;
+ // src/DependencyInjection/Compiler/MailTransportPass.php
+ namespace App\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;
- use AppBundle\Mail\TransportChain;
+ use App\Mail\TransportChain;
class MailTransportPass implements CompilerPassInterface
{
@@ -248,11 +248,11 @@ In order to run the compiler pass when the container is compiled, you have to
add the compiler pass to the container in the ``build()`` method of your
bundle::
- // src/AppBundle/AppBundle.php
+ // src/AppBundle.php
// ...
use Symfony\Component\DependencyInjection\ContainerBuilder;
- use AppBundle\DependencyInjection\Compiler\MailTransportPass;
+ use App\DependencyInjection\Compiler\MailTransportPass;
class AppBundle extends Bundle
{
@@ -424,21 +424,21 @@ first constructor argument to the ``App\HandlerCollection`` service:
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
- AppBundle\Handler\One:
+ App\Handler\One:
tags: [app.handler]
- AppBundle\Handler\Two:
+ App\Handler\Two:
tags: [app.handler]
- AppBundle\HandlerCollection:
+ App\HandlerCollection:
# inject all services tagged with app.handler as first argument
arguments: [!tagged app.handler]
.. code-block:: xml
-
+
-
+
-
+
-
+
@@ -463,16 +463,16 @@ first constructor argument to the ``App\HandlerCollection`` service:
.. code-block:: php
- // app/config/services.php
+ // config/services.php
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
- $container->register(AppBundle\Handler\One::class)
+ $container->register(App\Handler\One::class)
->addTag('app.handler');
- $container->register(AppBundle\Handler\Two::class)
+ $container->register(App\Handler\Two::class)
->addTag('app.handler');
- $container->register(AppBundle\HandlerCollection::class)
+ $container->register(App\HandlerCollection::class)
// inject all services tagged with app.handler as first argument
->addArgument(new TaggedIteratorArgument('app.handler'));
@@ -481,7 +481,7 @@ application handlers.
.. code-block:: php
- // src/AppBundle/HandlerCollection.php
+ // src/HandlerCollection.php
namespace AppBundle;
class HandlerCollection
@@ -499,15 +499,15 @@ application handlers.
.. code-block:: yaml
- # app/config/services.yml
+ # config/services.yaml
services:
- AppBundle\Handler\One:
+ App\Handler\One:
tags:
- { name: app.handler, priority: 20 }
.. code-block:: xml
-
+
-
+
@@ -523,8 +523,8 @@ application handlers.
.. code-block:: php
- // app/config/services.php
- $container->register(AppBundle\Handler\One::class)
+ // config/services.php
+ $container->register(App\Handler\One::class)
->addTag('app.handler', array('priority' => 20));
Note that any other custom attributes will be ignored by this feature.
diff --git a/session/locale_sticky_session.rst b/session/locale_sticky_session.rst
index 4e89eb2ffc2..7a4ae4307cd 100644
--- a/session/locale_sticky_session.rst
+++ b/session/locale_sticky_session.rst
@@ -17,8 +17,8 @@ Create and a :ref:`new event subscriber `. Typically, ``_loca
is used as a routing parameter to signify the locale, though you can determine the
correct locale however you want::
- // src/AppBundle/EventSubscriber/LocaleSubscriber.php
- namespace AppBundle\EventSubscriber;
+ // src/EventSubscriber/LocaleSubscriber.php
+ namespace App\EventSubscriber;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -58,7 +58,7 @@ correct locale however you want::
}
}
-If you're using the :ref:`default services.yml configuration `,
+If you're using the :ref:`default services.yaml configuration `,
you're done! Symfony will automatically know about the event subscriber and call
the ``onKernelRequest`` method on each request.
@@ -76,7 +76,7 @@ via some "Change Locale" route & controller), or create a route with a the :ref:
services:
# ...
- AppBundle\EventSubscriber\LocaleSubscriber:
+ App\EventSubscriber\LocaleSubscriber:
arguments: ['%kernel.default_locale%']
# redundant if you're using autoconfigure
tags: [kernel.event_subscriber]
@@ -90,7 +90,7 @@ via some "Change Locale" route & controller), or create a route with a the :ref:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
%kernel.default_locale%
@@ -100,7 +100,7 @@ via some "Change Locale" route & controller), or create a route with a the :ref:
.. code-block:: php
- use AppBundle\EventSubscriber\LocaleSubscriber;
+ use App\EventSubscriber\LocaleSubscriber;
$container->register(LocaleSubscriber::class)
->addArgument('%kernel.default_locale%')
@@ -139,8 +139,8 @@ event:
.. code-block:: php
- // src/AppBundle/EventSubscriber/UserLocaleSubscriber.php
- namespace AppBundle\EventSubscriber;
+ // src/EventSubscriber/UserLocaleSubscriber.php
+ namespace App\EventSubscriber;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
@@ -172,7 +172,7 @@ event:
}
}
-If you're using the :ref:`default services.yml configuration `,
+If you're using the :ref:`default services.yaml configuration `,
you're done! Symfony will automatically know about the event subscriber will pass
your the ``session`` service. Now, when you login, the user's locale will be set
into the session.
diff --git a/session/proxy_examples.rst b/session/proxy_examples.rst
index 4e5c34e66ba..82f636b7616 100644
--- a/session/proxy_examples.rst
+++ b/session/proxy_examples.rst
@@ -11,7 +11,7 @@ a custom save handler just by defining a class that extends the
class.
Then, define the class as a :ref:`service `.
-If you're using the :ref:`default services.yml configuration `,
+If you're using the :ref:`default services.yaml configuration `,
that happens automatically.
Finally, use the ``framework.session.handler_id`` configuration option to tell
@@ -25,7 +25,7 @@ Symfony to use your session handler instead of the default one:
framework:
session:
# ...
- handler_id: AppBundle\Session\CustomSessionHandler
+ handler_id: App\Session\CustomSessionHandler
.. code-block:: xml
@@ -38,14 +38,14 @@ Symfony to use your session handler instead of the default one:
http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
.. code-block:: php
// app/config/config.php
- use AppBundle\Session\CustomSessionHandler;
+ use App\Session\CustomSessionHandler;
$container->loadFromExtension('framework', array(
// ...
'session' => array(
@@ -65,8 +65,8 @@ If you want to encrypt the session data, you can use the proxy to encrypt and
decrypt the session as required. The following example uses the `php-encryption`_
library, but you can adapt it to any other library that you may be using::
- // src/AppBundle/Session/EncryptedSessionProxy.php
- namespace AppBundle\Session;
+ // src/Session/EncryptedSessionProxy.php
+ namespace App\Session;
use Defuse\Crypto\Crypto;
use Defuse\Crypto\Key;
@@ -105,10 +105,10 @@ There are some applications where a session is required for guest users, but
where there is no particular need to persist the session. In this case you
can intercept the session before it is written::
- // src/AppBundle/Session/ReadOnlySessionProxy.php
- namespace AppBundle\Session;
+ // src/Session/ReadOnlySessionProxy.php
+ namespace App\Session;
- use AppBundle\Entity\User;
+ use App\Entity\User;
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
diff --git a/setup/built_in_web_server.rst b/setup/built_in_web_server.rst
index bf31ab77780..220d25c6d40 100644
--- a/setup/built_in_web_server.rst
+++ b/setup/built_in_web_server.rst
@@ -31,8 +31,8 @@ First, execute this command:
Then, enable the bundle in the kernel of the application::
- // app/AppKernel.php
- class AppKernel extends Kernel
+ // src/Kernel.php
+ class Kernel extends Kernel
{
public function registerBundles()
{
diff --git a/setup/file_permissions.rst b/setup/file_permissions.rst
index 5c5b8fbb8c7..89fb4157f82 100644
--- a/setup/file_permissions.rst
+++ b/setup/file_permissions.rst
@@ -70,7 +70,7 @@ If none of the previous methods work for you, change the umask so that the
cache and log directories are group-writable or world-writable (depending
if the web server user and the command line user are in the same group or not).
To achieve this, put the following line at the beginning of the ``bin/console``,
-``web/app.php`` and ``web/app_dev.php`` files::
+``public/index.php`` and ``public/index.php`` files::
umask(0002); // This will let the permissions be 0775
diff --git a/setup/flex.rst b/setup/flex.rst
index 17715c8910c..bc050268a5b 100644
--- a/setup/flex.rst
+++ b/setup/flex.rst
@@ -160,9 +160,9 @@ these manual steps:
new ``config/services.yaml`` and ``.env`` files depending on your needs.
#. Move the original source code from ``src/{App,...}Bundle/`` to ``src/`` and
update the namespaces of every PHP file (advanced IDEs can do this automatically).
-#. Move the original templates from ``app/Resources/views/`` to ``templates/``
+#. Move the original templates from ``templates/`` to ``templates/``
#. Make any other change needed by your application. For example, if your original
- ``web/app_*.php`` front controllers were customized, add those changes to the
+ ``public/app_*.php`` front controllers were customized, add those changes to the
new ``public/index.php`` controller.
.. _`Symfony Flex`: https://github.com/symfony/flex
diff --git a/setup/new_project_svn.rst b/setup/new_project_svn.rst
index 073d76ca698..beb81b39175 100644
--- a/setup/new_project_svn.rst
+++ b/setup/new_project_svn.rst
@@ -86,7 +86,7 @@ with these steps:
$ svn propset svn:ignore "bundles" web
- $ svn ci -m "commit basic Symfony ignore list (vendor, var/bootstrap*, app/config/parameters.yml, var/cache/*, var/log/*, web/bundles)"
+ $ svn ci -m "commit basic Symfony ignore list (vendor, var/bootstrap*, app/config/parameters.yml, var/cache/*, var/log/*, public/bundles)"
#. The rest of the files can now be added and committed to the project:
diff --git a/setup/web_server_configuration.rst b/setup/web_server_configuration.rst
index 9a0b439aa07..1825a0a0faa 100644
--- a/setup/web_server_configuration.rst
+++ b/setup/web_server_configuration.rst
@@ -19,15 +19,15 @@ to use PHP :ref:`with Nginx `.
The web directory is the home of all of your application's public and
static files, including images, stylesheets and JavaScript files. It is
- also where the front controllers (``app.php`` and ``app_dev.php``) live.
+ also where the front controllers (``index.php`` and ``index.php``) live.
The web directory serves as the document root when configuring your
- web server. In the examples below, the ``web/`` directory will be the
- document root. This directory is ``/var/www/project/web/``.
+ web server. In the examples below, the ``public/`` directory will be the
+ document root. This directory is ``/var/www/project/public/``.
- If your hosting provider requires you to change the ``web/`` directory to
+ If your hosting provider requires you to change the ``public/`` directory to
another location (e.g. ``public_html/``) make sure you
- :ref:`override the location of the web/ directory `.
+ :ref:`override the location of the public/ directory `.
.. _web-server-apache-mod-php:
@@ -83,7 +83,7 @@ and increase web server performance:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^(.*)$ app.php [QSA,L]
+ RewriteRule ^(.*)$ index.php [QSA,L]
@@ -96,7 +96,7 @@ and increase web server performance:
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
-
+
RewriteEngine Off
@@ -187,11 +187,11 @@ use the ``SetHandler`` directive to pass requests for PHP files to PHP FPM:
# If you use Apache version below 2.4.9 you must consider update or use this instead
- # ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/web/$1
+ # ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
# If you run your Symfony application on a subpath of your document root, the
# regular expression must be changed accordingly:
- # ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/web/$1
+ # ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
DocumentRoot /var/www/project/web
@@ -267,12 +267,12 @@ The **minimum configuration** to get your application running under Nginx is:
root /var/www/project/web;
location / {
- # try to serve file directly, fallback to app.php
- try_files $uri /app.php$is_args$args;
+ # try to serve file directly, fallback to index.php
+ try_files $uri /index.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
- # In production, don't include this and don't deploy app_dev.php or config.php
+ # In production, don't include this and don't deploy index.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php7.1-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
@@ -302,7 +302,7 @@ The **minimum configuration** to get your application running under Nginx is:
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
- # http://domain.tld/app.php/some-path
+ # http://domain.tld/index.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
@@ -324,7 +324,7 @@ The **minimum configuration** to get your application running under Nginx is:
.. tip::
- This executes **only** ``app.php``, ``app_dev.php`` and ``config.php`` in
+ This executes **only** ``index.php``, ``index.php`` and ``config.php`` in
the web directory. All other files ending in ".php" will be denied.
If you have other PHP files in your web directory that need to be executed,
@@ -332,8 +332,8 @@ The **minimum configuration** to get your application running under Nginx is:
.. caution::
- After you deploy to production, make sure that you **cannot** access the ``app_dev.php``
- or ``config.php`` scripts (i.e. ``http://example.com/app_dev.php`` and ``http://example.com/config.php``).
+ After you deploy to production, make sure that you **cannot** access the ``index.php``
+ or ``config.php`` scripts (i.e. ``http://example.com/index.php`` and ``http://example.com/config.php``).
If you *can* access these, be sure to remove the ``DEV`` section from the above configuration.
.. note::
diff --git a/templating.rst b/templating.rst
index f04a54735ae..1a6dbe06b52 100644
--- a/templating.rst
+++ b/templating.rst
@@ -174,7 +174,7 @@ First, build a base layout file:
.. code-block:: html+twig
- {# app/Resources/views/base.html.twig #}
+ {# templates/base.html.twig #}
@@ -199,7 +199,7 @@ First, build a base layout file:
.. code-block:: html+php
-
+
@@ -242,7 +242,7 @@ A child template might look like this:
.. code-block:: html+twig
- {# app/Resources/views/blog/index.html.twig #}
+ {# templates/blog/index.html.twig #}
{% extends 'base.html.twig' %}
{% block title %}My cool blog posts{% endblock %}
@@ -256,7 +256,7 @@ A child template might look like this:
.. code-block:: html+php
-
+
extend('base.html.php') ?>
set('title', 'My cool blog posts') ?>
@@ -270,7 +270,7 @@ A child template might look like this:
.. note::
- The parent template is stored in ``app/Resources/views/``, so its path is
+ The parent template is stored in ``templates/``, so its path is
simply ``base.html.twig``. The template naming conventions are explained
fully in :ref:`template-naming-locations`.
@@ -357,7 +357,7 @@ Template Naming and Locations
By default, templates can live in two different locations:
-``app/Resources/views/``
+``templates/``
The application's ``views`` directory can contain application-wide base templates
(i.e. your application's layouts and templates of the application bundle) as
well as templates that override third party bundle templates
@@ -368,11 +368,11 @@ By default, templates can live in two different locations:
directory (and subdirectories). When you plan to share your bundle, you should
put the templates in the bundle instead of the ``app/`` directory.
-Most of the templates you'll use live in the ``app/Resources/views/``
+Most of the templates you'll use live in the ``templates/``
directory. The path you'll use will be relative to this directory. For example,
-to render/extend ``app/Resources/views/base.html.twig``, you'll use the
+to render/extend ``templates/base.html.twig``, you'll use the
``base.html.twig`` path and to render/extend
-``app/Resources/views/blog/index.html.twig``, you'll use the
+``templates/blog/index.html.twig``, you'll use the
``blog/index.html.twig`` path.
.. _template-referencing-in-bundle:
@@ -479,7 +479,7 @@ template. First, create the template that you'll need to reuse.
.. code-block:: html+twig
- {# app/Resources/views/article/article_details.html.twig #}
+ {# templates/article/article_details.html.twig #}
{{ article.title }}
by {{ article.authorName }}
@@ -489,7 +489,7 @@ template. First, create the template that you'll need to reuse.
.. code-block:: html+php
-
+
getTitle() ?>
by getAuthorName() ?>
@@ -503,7 +503,7 @@ Including this template from any other template is simple:
.. code-block:: html+twig
- {# app/Resources/views/article/list.html.twig #}
+ {# templates/article/list.html.twig #}
{% extends 'layout.html.twig' %}
{% block body %}
@@ -565,7 +565,7 @@ configuration:
.. code-block:: php-annotations
- // src/AppBundle/Controller/WelcomeController.php
+ // src/Controller/WelcomeController.php
// ...
use Symfony\Component\Routing\Annotation\Route;
@@ -583,14 +583,14 @@ configuration:
.. code-block:: yaml
- # app/config/routing.yml
+ # config/routes.yaml
welcome:
path: /
defaults: { _controller: AppBundle:Welcome:index }
.. code-block:: xml
-
+
+
{{ article.title }}
@@ -702,7 +702,7 @@ correctly:
.. code-block:: html+php
-
+
output('title', 'Hello Application') ?>
@@ -238,14 +238,14 @@ Create a ``hello.html.php`` template:
.. code-block:: html+php
-
+
Hello !
And change the ``index.html.php`` template to include it:
.. code-block:: html+php
-
+
extend('AppBundle::layout.html.php') ?>
render('AppBundle:Hello:hello.html.php', array('name' => $name)) ?>
@@ -268,7 +268,7 @@ If you create a ``fancy`` action, and want to include it into the
.. code-block:: html+php
-
+
render(
new \Symfony\Component\HttpKernel\Controller\ControllerReference('AppBundle:Hello:fancy', array(
'name' => $name,
@@ -279,7 +279,7 @@ If you create a ``fancy`` action, and want to include it into the
Here, the ``AppBundle:Hello:fancy`` string refers to the ``fancy`` action of the
``Hello`` controller::
- // src/AppBundle/Controller/HelloController.php
+ // src/Controller/HelloController.php
class HelloController extends Controller
{
@@ -332,7 +332,7 @@ pattern:
.. code-block:: yaml
- # src/AppBundle/Resources/config/routing.yml
+ # src/Resources/config/routing.yml
hello: # The route name
path: /hello/{name}
defaults: { _controller: AppBundle:Hello:index }
diff --git a/templating/debug.rst b/templating/debug.rst
index 6e3e531db52..691dd2f731b 100644
--- a/templating/debug.rst
+++ b/templating/debug.rst
@@ -12,8 +12,8 @@ When using PHP, you can use the
if you need to quickly find the value of a variable passed. This is useful,
for example, inside your controller::
- // src/AppBundle/Controller/ArticleController.php
- namespace AppBundle\Controller;
+ // src/Controller/ArticleController.php
+ namespace App\Controller;
// ...
@@ -37,7 +37,7 @@ The same mechanism can be used in Twig templates thanks to ``dump()`` function:
.. code-block:: html+twig
- {# app/Resources/views/article/recent_list.html.twig #}
+ {# templates/article/recent_list.html.twig #}
{{ dump(articles) }}
{% for article in articles %}
diff --git a/templating/embedding_controllers.rst b/templating/embedding_controllers.rst
index 228ae4053ee..008a4c68fbd 100644
--- a/templating/embedding_controllers.rst
+++ b/templating/embedding_controllers.rst
@@ -19,8 +19,8 @@ The solution is to simply embed the result of an entire controller from your
template. First, create a controller that renders a certain number of recent
articles::
- // src/AppBundle/Controller/ArticleController.php
- namespace AppBundle\Controller;
+ // src/Controller/ArticleController.php
+ namespace App\Controller;
// ...
@@ -45,7 +45,7 @@ The ``recent_list`` template is perfectly straightforward:
.. code-block:: html+twig
- {# app/Resources/views/article/recent_list.html.twig #}
+ {# templates/article/recent_list.html.twig #}
{% for article in articles %}
{{ article.title }}
@@ -54,7 +54,7 @@ The ``recent_list`` template is perfectly straightforward:
.. code-block:: html+php
-
+
getTitle() ?>
@@ -74,7 +74,7 @@ string syntax for controllers (i.e. **bundle**:**controller**:**action**):
.. code-block:: html+twig
- {# app/Resources/views/base.html.twig #}
+ {# templates/base.html.twig #}
{# ... #}