Skip to content

Very unclear message when missing use statements and annotation loader #14199

@linaori

Description

@linaori

I was struggling to debug why I got a circular reference error trying to add my controller to a new application. The controller below with the config in routing.yml should be able to reproduce this. I found out that the error is triggered by a missing use statement: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; as I used @Template(). I get the same error if the @Route use statement is missing.

This error is very unclear and should be able to get a better message.

FileLoaderImportCircularReferenceException in FileLoader.php line 97:
Circular reference detected in "/home/ivanderberg/projects/login/www/app/config/routing.yml" ("/home/ivanderberg/projects/login/www/app/config/routing.yml" > "/home/ivanderberg/projects/login/www/src/App/Controller" > "/home/ivanderberg/projects/login/www/app/config/routing.yml").
// routing.yml
app:
    resource: "@App/Controller"
    type:     annotation
    prefix:   /
<?php
namespace App\Controller\Auth;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
 * @Route(service="app.controller.auth.login")
 */
class LoginController
{
    /**
     * @Route("/", name="app.auth.login")
     * @Template()
     */
    public function loginAction()
    {
        return [];
    }
}

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