Symfony,路由错误

时间:2016-06-29 08:48:08

标签: php symfony routing

我有一个Symfony控制器

class apiDictionaryController extends Controller
{
    /**
     * @Route("/api/dictionary_list/{userId}/{sessionKey}", name="api/dictionary_list")
     */

    public function dictionaryListAction($userId=null, $sessionKey=null)
    {
        // Security check
        $security = $this->get('app.security');
        $security->userId = $userId;
        $security->sessionKey = $sessionKey;
        $response = new Response();
        if (!$security->sessionKeyIsValid())
        {
            $response->setStatusCode(400, 'Session key has expiried ['.$sessionKey.'] for user ['.$userId.']');
            return $response;
        }
        // Get content
        $statement = $this->get('database_connection')
            ->prepare('select * from main.service_dictionary_cursor()');
        $statement->execute();
        // Set content
        $response->setCharset('UTF-8');
        $response->setContent(json_encode($statement->FetchAll(), JSON_UNESCAPED_UNICODE));
        return $response;
    }

}

在生产环境中返回404错误。 http://XXX.XXX.XXX.XXX/api/dictionary_list/3/a4767716-c68f-40f1-b3cc-fce272eb2e60

我清除了缓存(删除了/ var / cache / prod中的所有文件),但它没有帮助。

当我尝试

sudo php bin/console debug:router --env=prod

我可以看到

 --------------------- -------- -------- ------ --------------------------------------------------------------------
  Name                  Method   Scheme   Host   Path
 --------------------- -------- -------- ------ --------------------------------------------------------------------
  api/dictionary_list   ANY      ANY      ANY    /api/message_list/{userId}/{sessionKey}/{parcelId}
  api/message_create    ANY      ANY      ANY    /api/message_create/{userId}/{sessionKey}/{parcelId}/{messageText}
  api/parcel_list       ANY      ANY      ANY    /api/parcel_list/{userId}/{sessionKey}/{showDate}/{statusId}
  api/parcel_content    ANY      ANY      ANY    /api/parcel_content/{userId}/{sessionKey}/{parcelId}
  api/login             ANY      ANY      ANY    /api/login/{login}/{password}
  app_index_index       ANY      ANY      ANY    /
  profile               ANY      ANY      ANY    /profile/{userId}/{sessionKey}
  login                 ANY      ANY      ANY    /login
 --------------------- -------- -------- ------ --------------------------------------------------------------------

为什么第一个字符串指向路径/api/message_list/{userId}/{sessionKey}/{parcelId}而不是/api/dictonary_list/{userId}/{sessionKey}/{parcelId}以及如何修复它?

0 个答案:

没有答案