title: Symfony - twig - Autoloader expected class
body: <p>I have a problem with symfony and apparently twig.
  I've been working on a project for some time, and as I was about to make a new release (by uploading everything througn ftp, following this : <a href="https://medium.com/@runawaycoin/deploying-symfony-4-application-to-shared-hosting-with-just-ftp-access-e65d2c5e0e3d" rel="nofollow noreferrer">https://medium.com/@runawaycoin/deploying-symfony-4-application-to-shared-hosting-with-just-ftp-access-e65d2c5e0e3d</a>).</p>
  
  <p>Just before doing the upload, I discover that the application stopped working a day before. I start to search for the issue, but there wasn't anything in the logs. I decide to reupload everything and clear the cache, in case that could be the problem, but still nothing, just a 500 error.</p>
  
  <p>I then enable the debug, and get the error : </p>
  
  <pre><code>The autoloader expected class "Twig\Extension\AbstractExtension" to be defined in file ".../symfony/vendor/composer/../twig/twig/src/Extension/AbstractExtension.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
  </code></pre>
  
  <p>I tried everything I could find online, but the only one who had a similar problem solved it by adding twig/extensions, but this does not solve it either.</p>
  
  <p>I don't get at all what may have happened, but this problem seemed to have appeared with no reason, and without any file change.</p>
  
  <p>The application did work before, and still works offline.</p>
  
  <p>Here's the code of the AbstractExtension.php, which is the same as on the twigphp/twig repo : </p>
  
  <pre><code>&lt;?php
  
  namespace Twig\Extension;
  
  class_exists('Twig_Extension');
  
  if (\false) {
      class AbstractExtension extends \Twig_Extension
      {
      }
  }
  </code></pre>
  
  <p>PS : this if false sounds weird but is the same as online so i don't get it</p>
  
  <p>EDIT : here's the log as text : </p>
  
  <pre><code>(1/1) RuntimeException
  The autoloader expected class "Twig\Extension\AbstractExtension" to be defined in file "/home/homeviewcx/symfony/vendor/composer/../twig/twig/src/Extension/AbstractExtension.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
  
  in DebugClassLoader.php line 288
  at DebugClassLoader-&gt;checkClass('Twig\\Extension\\AbstractExtension', '/home/homeviewcx/symfony/vendor/composer/../twig/twig/src/Extension/AbstractExtension.php')
  in DebugClassLoader.php line 159
  at DebugClassLoader-&gt;loadClass('Twig\\Extension\\AbstractExtension')
  at spl_autoload_call('Twig\\Extension\\AbstractExtension')
  in CsrfExtension.php line 21
  at require('/home/homeviewcx/symfony/vendor/symfony/twig-bridge/Extension/CsrfExtension.php')
  in DebugClassLoader.php line 145
  at DebugClassLoader-&gt;loadClass('Symfony\\Bridge\\Twig\\Extension\\CsrfExtension')
  at spl_autoload_call('Symfony\\Bridge\\Twig\\Extension\\CsrfExtension')
  at class_exists('Symfony\\Bridge\\Twig\\Extension\\CsrfExtension')
  in FrameworkExtension.php line 1240
  at FrameworkExtension-&gt;registerSecurityCsrfConfiguration(array('enabled' =&gt; true), object(MergeExtensionConfigurationContainerBuilder), object(XmlFileLoader))
  in FrameworkExtension.php line 205
  at FrameworkExtension-&gt;load(array(array('router' =&gt; array('resource' =&gt; 'kernel::loadRoutes', 'type' =&gt; 'service')), array('secret' =&gt; 'env_d3d895c31330f4ea_APP_SECRET_dd4bd60cef72a43e4dea38ee2ba60137', 'session' =&gt; array('handler_id' =&gt; null), 'php_errors' =&gt; array('log' =&gt; true), 'cache' =&gt; null), array('router' =&gt; array('strict_requirements' =&gt; null)), array('default_locale' =&gt; 'en', 'translator' =&gt; array('paths' =&gt; array('/home/homeviewcx/symfony/translations'), 'fallbacks' =&gt; array('en'))), array('validation' =&gt; array('email_validation_mode' =&gt; 'html5')), array('cache' =&gt; array('pools' =&gt; array('doctrine.result_cache_pool' =&gt; array('adapter' =&gt; 'cache.app'), 'doctrine.system_cache_pool' =&gt; array('adapter' =&gt; 'cache.system'))))), object(MergeExtensionConfigurationContainerBuilder))
  in MergeExtensionConfigurationPass.php line 76
  at MergeExtensionConfigurationPass-&gt;process(object(ContainerBuilder))
  in MergeExtensionConfigurationPass.php line 39
  at MergeExtensionConfigurationPass-&gt;process(object(ContainerBuilder))
  in Compiler.php line 95
  at Compiler-&gt;compile(object(ContainerBuilder))
  in ContainerBuilder.php line 746
  at ContainerBuilder-&gt;compile()
  in Kernel.php line 519
  at Kernel-&gt;initializeContainer()
  in Kernel.php line 123
  at Kernel-&gt;boot()
  in Kernel.php line 183
  at Kernel-&gt;handle(object(Request))
  in app.php line 50
  </code></pre>
  
  <p>here's my composer.json : </p>
  
  <pre><code>    {
      "type": "project",
      "license": "proprietary",
      "require": {
          "php": "^7.1.3",
          "ext-iconv": "*",
          "sensio/framework-extra-bundle": "^5.1",
          "symfony/apache-pack": "^1.0",
          "symfony/asset": "^4.1",
          "symfony/config": "^4.1",
          "symfony/console": "^4.1",
          "symfony/dependency-injection": "^4.1",
          "symfony/expression-language": "^4.1",
          "symfony/flex": "^1.0",
          "symfony/form": "^4.1",
          "symfony/framework-bundle": "^4.1",
          "symfony/lts": "^4@dev",
          "symfony/monolog-bundle": "^3.1",
          "symfony/orm-pack": "*",
          "symfony/process": "^4.1",
          "symfony/security-bundle": "^4.1",
          "symfony/serializer-pack": "*",
          "symfony/swiftmailer-bundle": "^3.1",
          "symfony/twig-bundle": "^4.1",
          "symfony/validator": "^4.1",
          "symfony/web-link": "^4.1",
          "symfony/yaml": "^4.1"
      },
      "require-dev": {
          "symfony/debug-pack": "*",
          "symfony/dotenv": "^4.1",
          "symfony/maker-bundle": "^1.0",
          "symfony/profiler-pack": "*",
          "symfony/test-pack": "^1.0",
          "symfony/web-server-bundle": "^4.1"
      },
      "config": {
          "preferred-install": {
              "*": "dist"
          },
          "sort-packages": true
      },
      "autoload": {
          "psr-4": {
              "App\\": "src/"
          }
      },
      "autoload-dev": {
          "psr-4": {
              "App\\Tests\\": "tests/"
          }
      },
      "replace": {
          "symfony/polyfill-iconv": "*",
          "symfony/polyfill-php71": "*",
          "symfony/polyfill-php70": "*",
          "symfony/polyfill-php56": "*"
      },
      "scripts": {
          "auto-scripts": {
              "cache:clear": "symfony-cmd",
              "assets:install %PUBLIC_DIR%": "symfony-cmd"
          },
          "post-install-cmd": [
              "@auto-scripts"
          ],
          "post-update-cmd": [
              "@auto-scripts"
          ],
          "prod": [
            "SET APP_ENV=prod",
            "composer install --no-dev --optimize-autoloader",
            "composer dump-autoload --optimize --no-dev --classmap-authoritative"
          ],
          "dev": [
            "SET APP_ENV=dev",
            "composer install"
          ]
      },
      "conflict": {
          "symfony/symfony": "*"
      },
      "extra": {
          "symfony": {
              "allow-contrib": false
          }
      }
  }
  </code></pre>
  
  <p>PS: I'm personally not extending the AbstractExtension class anywhere (nor any other twig classes), and haven't touched the container compiler either (still relatively new here), but yes, that might be it</p>