diff --git a/.gitignore b/.gitignore
index e83aa85..d4acd14 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/var/
 /vendor/
 /composer.phar
 /composer.lock
diff --git a/.php_cs.dist b/.php_cs.dist
index 2bb967f..b7190bb 100644
--- a/.php_cs.dist
+++ b/.php_cs.dist
@@ -2,6 +2,7 @@
 
 $finder = PhpCsFixer\Finder::create()
     ->in(__DIR__)
+    ->exclude('var')
     ->exclude('Tests/Functional/cache')
 ;
 
diff --git a/Tests/Functional/Controller/ApiController.php b/Tests/Functional/Controller/ApiController.php
index d54c808..c79eaab 100644
--- a/Tests/Functional/Controller/ApiController.php
+++ b/Tests/Functional/Controller/ApiController.php
@@ -22,8 +22,8 @@ use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyConstraints;
 use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
 use Nelmio\ApiDocBundle\Tests\Functional\Form\DummyType;
 use Nelmio\ApiDocBundle\Tests\Functional\Form\UserType;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Swagger\Annotations as SWG;
+use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\Validator\Constraints\IsTrue;
 use Symfony\Component\Validator\Constraints\Regex;
 
diff --git a/Tests/Functional/Controller/BazingaController.php b/Tests/Functional/Controller/BazingaController.php
index c5c9241..e8b238d 100644
--- a/Tests/Functional/Controller/BazingaController.php
+++ b/Tests/Functional/Controller/BazingaController.php
@@ -13,8 +13,8 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
 
 use Nelmio\ApiDocBundle\Annotation\Model;
 use Nelmio\ApiDocBundle\Tests\Functional\Entity\BazingaUser;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Swagger\Annotations as SWG;
+use Symfony\Component\Routing\Annotation\Route;
 
 /**
  * @Route(host="api.example.com")
diff --git a/Tests/Functional/Controller/BazingaTypedController.php b/Tests/Functional/Controller/BazingaTypedController.php
index 8592da1..a1f4e9d 100644
--- a/Tests/Functional/Controller/BazingaTypedController.php
+++ b/Tests/Functional/Controller/BazingaTypedController.php
@@ -13,8 +13,8 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
 
 use Nelmio\ApiDocBundle\Annotation\Model;
 use Nelmio\ApiDocBundle\Tests\Functional\EntityExcluded\BazingaUserTyped;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Swagger\Annotations as SWG;
+use Symfony\Component\Routing\Annotation\Route;
 
 /**
  * @Route(host="api.example.com")
diff --git a/Tests/Functional/Controller/ClassApiController.php b/Tests/Functional/Controller/ClassApiController.php
index 4d92b8f..94df74d 100644
--- a/Tests/Functional/Controller/ClassApiController.php
+++ b/Tests/Functional/Controller/ClassApiController.php
@@ -12,8 +12,8 @@
 namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
 
 use Nelmio\ApiDocBundle\Annotation\Security;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Swagger\Annotations as SWG;
+use Symfony\Component\Routing\Annotation\Route;
 
 /**
  * @Route("/api", host="api.example.com")
diff --git a/Tests/Functional/Controller/JMSController.php b/Tests/Functional/Controller/JMSController.php
index 47742ef..2370614 100644
--- a/Tests/Functional/Controller/JMSController.php
+++ b/Tests/Functional/Controller/JMSController.php
@@ -21,8 +21,8 @@ use Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSChatRoomUser;
 use Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSChatUser;
 use Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSPicture;
 use Nelmio\ApiDocBundle\Tests\Functional\Entity\VirtualProperty;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Swagger\Annotations as SWG;
+use Symfony\Component\Routing\Annotation\Route;
 
 /**
  * @Route(host="api.example.com")
diff --git a/Tests/Functional/Controller/TestController.php b/Tests/Functional/Controller/TestController.php
index 07ae103..f7cf30d 100644
--- a/Tests/Functional/Controller/TestController.php
+++ b/Tests/Functional/Controller/TestController.php
@@ -11,8 +11,8 @@
 
 namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
 
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Swagger\Annotations as SWG;
+use Symfony\Component\Routing\Annotation\Route;
 
 /**
  * @Route("/test", host="api-test.example.com")
diff --git a/Tests/Functional/Controller/UndocumentedController.php b/Tests/Functional/Controller/UndocumentedController.php
index 6944b86..98fbe65 100644
--- a/Tests/Functional/Controller/UndocumentedController.php
+++ b/Tests/Functional/Controller/UndocumentedController.php
@@ -11,7 +11,7 @@
 
 namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
 
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Component\Routing\Annotation\Route;
 
 /**
  * @Route(host="api.example.com")
diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php
index 43d529b..745ce8c 100644
--- a/Tests/Functional/TestKernel.php
+++ b/Tests/Functional/TestKernel.php
@@ -104,21 +104,31 @@ class TestKernel extends Kernel
      */
     protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
     {
-        $c->loadFromExtension('framework', [
+        $framework = [
             'secret' => 'MySecretKey',
             'test' => null,
             'validation' => null,
             'form' => null,
-            'templating' => [
-                'engines' => ['twig'],
-            ],
             'serializer' => ['enable_annotations' => true],
-        ]);
+        ];
+
+        // templating is deprecated
+        if (Kernel::VERSION_ID <= 40300) {
+            $framework['templating'] = ['engines' => ['twig']];
+        }
+
+        $c->loadFromExtension('framework', $framework);
 
         $c->loadFromExtension('twig', [
             'strict_variables' => '%kernel.debug%',
         ]);
 
+        $c->loadFromExtension('sensio_framework_extra', [
+            'router' => [
+                'annotations' => false,
+            ],
+        ]);
+
         $c->loadFromExtension('api_platform', [
             'mapping' => ['paths' => ['%kernel.project_dir%/Tests/Functional/Entity']],
         ]);
diff --git a/composer.json b/composer.json
index 95aede5..526237d 100644
--- a/composer.json
+++ b/composer.json
@@ -37,7 +37,8 @@
         "symfony/cache": "^3.4|^4.0",
         "symfony/phpunit-bridge": "^3.4.24|^4.0",
         "symfony/stopwatch": "^3.4|^4.0",
-        "sensio/framework-extra-bundle": "^3.0",
+        "symfony/routing": "^3.4|^4.0",
+        "sensio/framework-extra-bundle": "^3.0.13|^4.0|^5.0",
         "doctrine/annotations": "^1.2",
         "doctrine/common": "^2.4",