Why is this Symfony annotation not working?

Before I start, I should mention that this is Symfony 2.8.25. (I just started working on this code base, and once we get some critical issues resolved, we'll be upgrading.)

I have an existing class using annotations with a number of routes that work fine.

I added a new one, and I get a 404 on that one every time. I did a console cache:clear which did not help. When I did a console debug:route, the new Routes appear in the list. But I still get a 404 on them, while the others in the same source file work.

All the routes use a POST, the working and non-working ones.

The routing.yml looks like this:

app:
    resource: '@AppBundle/Controller/'
    type: annotation

logout:
path: /logout

The class looks like this:

<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use AppBundle\Entity\Environment;
use AppBundle\Entity\Instance;
use AppBundle\Entity\Migration;
use AppBundle\Entity\UserActivity;
use AppBundle\Entity\Task;
use AppBundle\Form\Environment\EnvironmentType;
use AppBundle\Services\Api;
use AppBundle\Utils\HashRequest;

class EnvironmentController extends Controller
{

/**
*
* @Route(“/api/envtype/add”, name=“api_envtype_add”)
*
*/
public function addEnvtypeAction(Request $request){

When I try another route from this same class, it works. But not this new one.

I tried renaming the route, and that made no difference. I checked the annotation comment for TABs, since that’s a (semi-)known bug in older versions. No TABs in the annotation.

This annotation looks to me exactly like the others that work. (None of them have a @return, for example.)

PostMan reports No route found for “POST /api/envtype/add”

I am completely out of ideas.

#symfony

5 Likes46.60 GEEK