Skip to content

Can't make yaml routing to annotation/attribute rule work #8385

Description

@fpetrovic

Question

I have a problem to migrate routes from yaml file to annotations/attributes in controllers. I am using Rector 0.18.13 and I was following the documentation from rector/rector-symfony:
rector.php
`<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

use Rector\Symfony\Bridge\Symfony\Routing\SymfonyRoutesProvider;
use Rector\Symfony\Configs\Rector\ClassMethod\AddRouteAnnotationRector;
use Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterface;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->symfonyContainerPhp(DIR . '/tests/symfony-container.php');

$rectorConfig->singleton(SymfonyRoutesProvider::class);
$rectorConfig->alias(SymfonyRoutesProvider::class, SymfonyRoutesProviderInterface::class);

$rectorConfig->rule(AddRouteAnnotationRector::class);

};`

tests/symfony-container.php

`<?php

use App\Kernel;

$appKernel = new Kernel('test', false);
$appKernel->boot();

return $appKernel->getContainer();`

Command: dc exec php vendor/bin/rector process src --clear-cache --dry-run --debug

I debugged container that is set inside symfonyContainerPhp method and it consists all metadata about routing ( inside routing service)

It does not add anything to controllers, Debug shows it goes through all controller files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions