Skip to content

Lots of automated migrations to Symfony Flex structure #8569

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bundles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ of the most common elements of a bundle:
necessary).

``Resources/config/``
Houses configuration, including routing configuration (e.g. ``routing.yml``).
Houses configuration, including routing configuration (e.g. ``routes.yaml``).

``Resources/views/``
Holds templates organized by controller name (e.g. ``Random/index.html.twig``).

``Resources/public/``
Contains web assets (images, stylesheets, etc) and is copied or symbolically
linked into the project ``web/`` directory via the ``assets:install`` console
linked into the project ``public/`` directory via the ``assets:install`` console
command.

``Tests/``
Expand Down
8 changes: 4 additions & 4 deletions bundles/extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Other available loaders are the ``YamlFileLoader``, ``PhpFileLoader`` and
.. caution::

If you removed the default file with service definitions (i.e.
``app/config/services.yml``), make sure to also remove it from the
``config/services.yaml``), make sure to also remove it from the
``imports`` key in ``app/config/config.yml``.

Using Configuration to Change the Services
Expand Down Expand Up @@ -146,8 +146,8 @@ work in the same way, but the second one is for classes that contain PHP
annotations). Define the classes to compile as an array of their fully qualified
class names::

use AppBundle\Manager\UserManager;
use AppBundle\Utils\Slugger;
use App\Manager\UserManager;
use App\Utils\Slugger;

// ...
public function load(array $configs, ContainerBuilder $container)
Expand All @@ -163,7 +163,7 @@ class names::

// add here only classes that contain PHP annotations
$this->addAnnotatedClassesToCompile(array(
'AppBundle\\Controller\\DefaultController',
'App\\Controller\\DefaultController',
// ...
));
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/override.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Routing

Routing is never automatically imported in Symfony. If you want to include
the routes from any bundle, then they must be manually imported from somewhere
in your application (e.g. ``app/config/routing.yml``).
in your application (e.g. ``config/routes.yml``).

The easiest way to "override" a bundle's routing is to never import it at
all. Instead of importing a third-party bundle's routing, simply copy
Expand Down
8 changes: 4 additions & 4 deletions bundles/remove.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ that refers to the bundle.
~~~~~~~~~~~~~~~~~~~~~~~~~

*Some* bundles require you to import routing configuration. Check for references
to the bundle in ``app/config/routing.yml`` and ``app/config/routing_dev.yml``.
If you find any references, remove them completely.
to the bundle in the routing configuration (inside ``config/routes/``). If you
find any references, remove them completely.

2.2 Remove Bundle Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -74,8 +74,8 @@ directory, and any parent directories that are now empty (e.g. ``src/Acme/``).
3.1 Remove Bundle Assets
~~~~~~~~~~~~~~~~~~~~~~~~

Remove the assets of the bundle in the web/ directory (e.g.
``web/bundles/acmedemo`` for the AcmeDemoBundle).
Remove the assets of the bundle in the public/ directory (e.g.
``public/bundles/acmedemo`` for the AcmeDemoBundle).

4. Remove Integration in other Bundles
--------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion components/dependency_injection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Loading a YAML config file::

$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
$loader->load('services.yml');
$loader->load('services.yaml');

.. note::

Expand Down
2 changes: 1 addition & 1 deletion components/http_foundation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ represents an HTTP message. But when moving from a legacy system, adding
methods or changing some default behavior might help. In that case, register a
PHP callable that is able to create an instance of your ``Request`` class::

use AppBundle\Http\SpecialRequest;
use App\Http\SpecialRequest;
use Symfony\Component\HttpFoundation\Request;

Request::setFactory(function (
Expand Down
28 changes: 10 additions & 18 deletions components/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ routes with UTF-8 characters:

.. code-block:: php-annotations

// src/AppBundle/Controller/DefaultController.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to keep such comments? We can probably automatically just strip the AppBundle directory. The new one would be src/Controller/DefaultController.php in that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I changed it everywhere, but we're in the components section, we shouldn't talk about framework conventions here. (probably, this needs to be extracted to its own subguide).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, makes sense.

namespace AppBundle\Controller;
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
Expand All @@ -375,45 +374,42 @@ routes with UTF-8 characters:
/**
* @Route("/category/{name}", name="route1", options={"utf8": true})
*/
public function categoryAction()
public function category()
{
// ...
}

.. code-block:: yaml

# app/config/routing.yml
route1:
path: /category/{name}
defaults: { _controller: 'AppBundle:Default:category' }
defaults: { _controller: 'App\Controller\DefaultController::category' }
options:
utf8: true

.. code-block:: xml

<!-- app/config/routing.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="route1" path="/category/{name}">
<default key="_controller">AppBundle:Default:category</default>
<default key="_controller">App\Controller\DefaultController::category</default>
<option key="utf8">true</option>
</route>
</routes>

.. code-block:: php

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

$collection = new RouteCollection();
$collection->add('route1', new Route('/category/{name}',
array(
'_controller' => 'AppBundle:Default:category',
'_controller' => 'App\Controller\DefaultController::category',
),
array(),
array(
Expand All @@ -438,8 +434,7 @@ You can also include UTF-8 strings as routing requirements:

.. code-block:: php-annotations

// src/AppBundle/Controller/DefaultController.php
namespace AppBundle\Controller;
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
Expand All @@ -454,48 +449,45 @@ You can also include UTF-8 strings as routing requirements:
* options={"utf8": true}
* )
*/
public function defaultAction()
public function default()
{
// ...
}

.. code-block:: yaml

# app/config/routing.yml
route2:
path: /default/{default}
defaults: { _controller: 'AppBundle:Default:default' }
defaults: { _controller: 'App\Controller\DefaultController::default' }
requirements:
default: "한국어"
options:
utf8: true

.. code-block:: xml

<!-- app/config/routing.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="route2" path="/default/{default}">
<default key="_controller">AppBundle:Default:default</default>
<default key="_controller">App\Controller\DefaultController::default</default>
<requirement key="default">한국어</requirement>
<option key="utf8">true</option>
</route>
</routes>

.. code-block:: php

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

$collection = new RouteCollection();
$collection->add('route2', new Route('/default/{default}',
array(
'_controller' => 'AppBundle:Default:default',
'_controller' => 'App\Controller\DefaultController::default',
),
array(
'default' => '한국어',
Expand Down
8 changes: 4 additions & 4 deletions configuration/front_controllers_and_kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ The Front Controller
The `front controller`_ is a well-known design pattern; it is a section of
code that *all* requests served by an application run through.

In the `Symfony Standard Edition`_, this role is taken by the `app.php`_
and `app_dev.php`_ files in the ``web/`` directory. These are the very
first PHP scripts executed when a request is processed.
In the `Symfony Standard Edition`_, this role is taken by the `index.php`_ file
in the ``public/`` directory. This is the very first PHP script executed when a
request is processed.

The main purpose of the front controller is to create an instance of the
``AppKernel`` (more on that in a second), make it handle the request
Expand Down Expand Up @@ -160,7 +160,7 @@ way of loading your configuration.

.. _front controller: https://en.wikipedia.org/wiki/Front_Controller_pattern
.. _Symfony Standard Edition: https://github.com/symfony/symfony-standard
.. _app.php: https://github.com/symfony/symfony-standard/blob/master/web/app.php
.. _index.php: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php
.. _app_dev.php: https://github.com/symfony/symfony-standard/blob/master/web/app_dev.php
.. _bin/console: https://github.com/symfony/symfony-standard/blob/master/bin/console
.. _AppKernel: https://github.com/symfony/symfony-standard/blob/master/app/AppKernel.php
Expand Down
20 changes: 9 additions & 11 deletions console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ use it to create your own commands.
Creating a Command
------------------

Commands are defined in classes which should be created in the ``Command`` namespace
of your bundle (e.g. ``AppBundle\Command``) and their names should end with the
``Command`` suffix.
Commands are defined in classes extending
:class:`Symfony\\Component\\Console\\Command\\Command`. For example, you may
want a command to create a user::

For example, you may want a command to create a user::

// src/AppBundle/Command/CreateUserCommand.php
namespace AppBundle\Command;
// src/Command/CreateUserCommand.php
namespace App\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -74,7 +72,7 @@ terminal:

.. note::

If you're using the :ref:`default services.yml configuration <service-container-services-load-example>`,
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
your command classes are automatically registered as services.

You can also manually register your command as a service by configuring the service
Expand Down Expand Up @@ -228,10 +226,10 @@ useful one is the :class:`Symfony\\Component\\Console\\Tester\\CommandTester`
class. It uses special input and output classes to ease testing without a real
console::

// tests/AppBundle/Command/CreateUserCommandTest.php
namespace Tests\AppBundle\Command;
// tests/Command/CreateUserCommandTest.php
namespace App\Tests\Command;

use AppBundle\Command\CreateUserCommand;
use App\Command\CreateUserCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
Expand Down
8 changes: 4 additions & 4 deletions console/command_in_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Imagine you want to send spooled Swift Mailer messages by
:doc:`using the swiftmailer:spool:send command </email/spool>`.
Run this command from inside your controller via::

// src/AppBundle/Controller/SpoolController.php
namespace AppBundle\Controller;
// src/Controller/SpoolController.php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
Expand Down Expand Up @@ -76,8 +76,8 @@ First, require the package:

Now, use it in your controller::

// src/AppBundle/Controller/SpoolController.php
namespace AppBundle\Controller;
// src/Controller/SpoolController.php
namespace App\Controller;

use SensioLabs\AnsiConverter\AnsiToHtmlConverter;
use Symfony\Component\Console\Output\BufferedOutput;
Expand Down
12 changes: 6 additions & 6 deletions console/commands_as_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
How to Define Commands as Services
==================================

If you're using the :ref:`default services.yml configuration <service-container-services-load-example>`,
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
your command classes are already registered as services. Great! This is the
recommended setup.

Expand All @@ -26,7 +26,7 @@ using normal :ref:`dependency injection <services-constructor-injection>`.

For example, suppose you want to log something from within your command::

namespace AppBundle\Command;
namespace App\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -59,7 +59,7 @@ For example, suppose you want to log something from within your command::
}
}

If you're using the :ref:`default services.yml configuration <service-container-services-load-example>`,
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
the command class will automatically be registered as a service and passed the ``$logger``
argument (thanks to autowiring). In other words, *just* by creating this class, everything
works! You can call the ``app:sunshine`` command and start logging.
Expand Down Expand Up @@ -96,7 +96,7 @@ Or set the ``command`` attribute on the ``console.command`` tag in your service

services:

AppBundle\Command\SunshineCommand:
App\Command\SunshineCommand:
tags:
- { name: 'console.command', command: 'app:sunshine' }
# ...
Expand All @@ -110,7 +110,7 @@ Or set the ``command`` attribute on the ``console.command`` tag in your service

<services>

<service id="AppBundle\Command\SunshineCommand">
<service id="App\Command\SunshineCommand">
<tag name="console.command" command="app:sunshine" />
</service>

Expand All @@ -119,7 +119,7 @@ Or set the ``command`` attribute on the ``console.command`` tag in your service

.. code-block:: php

use AppBundle\Command\SunshineCommand;
use App\Command\SunshineCommand;

//...

Expand Down
4 changes: 2 additions & 2 deletions console/hide_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ executed through scheduled tasks, etc.
In those cases, you can define the command as **hidden** by setting the
``setHidden()`` method to ``true`` in the command configuration::

// src/AppBundle/Command/LegacyCommand.php
namespace AppBundle\Command;
// src/Command/LegacyCommand.php
namespace App\Command;

use Symfony\Component\Console\Command\Command;

Expand Down
2 changes: 1 addition & 1 deletion console/lazy_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The traditional way of adding commands to your application is to use
In order to lazy-load commands, you need to register an intermediate loader
which will be responsible for returning ``Command`` instances::

use AppBundle\Command\HeavyCommand;
use App\Command\HeavyCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\CommandLoader\FactoryCommmandLoader;

Expand Down
2 changes: 1 addition & 1 deletion console/request_context.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Configuring the Request Context per Command
To change it only in one command you can simply fetch the Request Context
from the ``router`` service and override its settings::

// src/AppBundle/Command/DemoCommand.php
// src/Command/DemoCommand.php

// ...
class DemoCommand extends ContainerAwareCommand
Expand Down
Loading