title: TYPO3: ViewHelper cannot be found
body: <p>I am currently facing a strange behaviour with <em>TYPO3 8.7</em>. To be more precise, what I do doesn't work on my machine, but it works on other machines and in our QA environment.</p>
  
  <p>I am building an extension where I need a simple <em>ViewHelper</em>. Unfortunately, every time I try to use my <em>ViewHelper</em>, I get the following exception:</p>
  
  <pre><code>#1407060572: Fluid parse error in template Default_action_Default_3595d4917583aa65277b432499e522ff39c573c7, line 48 at character 1. Error: The ViewHelper "&lt;website:string.idFromTitle&gt;" could not be resolved. Based on your spelling, the system would load the class "Domain\Website\ViewHelpers\String\IdFromTitleViewHelper", however this class does not exist. (error code 1407060572). Template source chunk: {title -&gt; website:string.idFromTitle(string: '{title}') -&gt; v:variable.set(name: 'targetId')} &lt;div class="alternative-content-lightbox-fce"&gt; &lt;div class="header"&gt; &lt;a href="#" class="lightbox-trigger" data-target="{targetId}"&gt;{linkTitle}&lt;/a&gt; &lt;h1&gt;{title}&lt;/h1&gt; &lt;/div&gt; &lt;div class="main-content"&gt;
  </code></pre>
  
  <p>I am using TYPO3 in "<em>Composer Mode</em>" with a "<em>composer.json</em>" file at the root of the installation and a "<em>composer.json</em>" file for the specific extension. In the main "<em>composer.json</em>" file, I have the following lines:</p>
  
  <pre><code>"repositories": {
      "website": {
          "type": "path",
          "url": "sources/website",
          "options": {
              "symlink": true
          }
      },
      ...
  }
  ...
  "require": {
      "domain/website": "@dev",
  }
  ...
  </code></pre>
  
  <p>So, the extension is set as local package.</p>
  
  <p>The "<em>composer.json</em>" file of my extension contains the following line:</p>
  
  <pre><code>"autoload": {
      "psr-4": {
          "Domain\\Website\\": "Classes"
      }
  }
  </code></pre>
  
  <p>In the "<em>autoload_classmap.php</em>" file, I can see the following line:</p>
  
  <pre><code>return array(
      'Domain\\Website\\ViewHelpers\\String\\IdFromTitleViewHelper' =&gt; $baseDir . '/Classes/ViewHelpers/String/IdFromTitleViewHelper.php'
  );
  </code></pre>
  
  <p>The "<em>autoload_static.php</em>" file has the following line:</p>
  
  <pre><code>public static $classMap = array (
      'Domain\\Website\\ViewHelpers\\String\\IdFromTitleViewHelper' =&gt; __DIR__ . '/../..' . '/Classes/ViewHelpers/String/IdFromTitleViewHelper.php',
  );
  </code></pre>
  
  <p>And finally, the "<em>autoload_psr4.php</em>" file contains the following line:</p>
  
  <pre><code>return array(
      'Domain\\Website\\' =&gt; array($baseDir . '/Classes'),
  );
  </code></pre>
  
  <p>So, I guess my file is autoloaded. The <em>ViewHelper</em> can be found in the directory "<em>Classes/ViewHelpers/String</em>" and it looks like so:</p>
  
  <pre><code>&lt;?php
  namespace Domain\Website\ViewHelpers\String;
  
  use TYPO3\CMS\Core\Utility\GeneralUtility;
  use TYPO3\CMS\Extbase\Object\ObjectManager;
  
  class IdFromTitleViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
  {
      public function initialize()
      {
      }
  
      public function render($string)
      {
          $id = trim($string);
          $id = strtolower($id);
          $id = str_replace(' ', '', $id);
          $id = preg_replace('/[^A-Za-z0-9\-]/', '', $id);
          $id .= uniqid();
  
          return $id;
      }
  }
  </code></pre>
  
  <p>When I use the <em>ViewHelper</em>, I do it like so:</p>
  
  <p>
  
  <pre><code>xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
  f:schemaLocation="https://fluidtypo3.org/schemas/fluid-master.xsd"
  
  xmlns:flux="http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers"
  flux:schemaLocation="https://fluidtypo3.org/schemas/flux-master.xsd"
  
  xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
  v:schemaLocation="https://fluidtypo3.org/schemas/vhs-master.xsd"
  
  xmlns:website="http://typo3.org/ns/Domain/Website/ViewHelpers"
  
  data-namespace-typo3-fluid="true"&gt;
  
  ...
  
  &lt;f:section name="Main"&gt;
  
      {title -&gt; website:string.idFromTitle(string: '{title}') -&gt; v:variable.set(name: 'targetId')}
  
      &lt;div class="alternative-content-lightbox-fce"&gt;
          &lt;div class="header"&gt;
              &lt;a href="#" class="lightbox-trigger" data-target="{targetId}"&gt;{linkTitle}&lt;/a&gt;
              &lt;h1&gt;{title}&lt;/h1&gt;
          &lt;/div&gt;
          &lt;div class="main-content"&gt;
              &lt;f:format.html&gt;{mainContent}&lt;/f:format.html&gt; 
          &lt;/div&gt;
          &lt;div id="{targetId}" class="alternative-content"&gt;
              &lt;f:format.html&gt;{alternativeContent}&lt;/f:format.html&gt; 
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;/f:section&gt;
  </code></pre>
  
  <p>Unfortunately, it does not work on my machine, but it works elsewhere. And I have the same problem with any other <em>ViewHelper</em> placed in "<em>Classes/ViewHelpers</em>", like if what is inside the "<em>Classes</em>" directory is ignored.</p>
  
  <p>I checked my <em>TYPO3</em> configuration, my <em>php.ini</em> file and my environment variables. I cleared the cache of <em>TYPO3</em> and <em>Composer</em> a thousand times. I reinstalled <em>TYPO3</em> completely. At first, I was using <em>TYPO3 8.7.27</em>, so I updated my installation to <em>8.7.28</em>, but it did not change anything. I even swapped the database with another one, just in case.</p>
  
  <p>My environment is a <em>Windows 10</em> environment using <em>Wamp 3.1.9 64bit</em> and <em>PHP 7.0.33</em>.</p>
  
  <p>The other thing that I noticed is the following one: when I run a <code>composer update</code>, when it comes to my package, I get the following error:</p>
  
  <pre><code>[RuntimeException]
  Package domain/website cannot install to "C:\wamp64\www\mysite\sources\website" inside its source at "C:\wamp64\www\mysite\sources\website"
  </code></pre>
  
  <p>I don't know if it is related, but it can give a hint. I thought of permissions problem, but everything seems to be fine.</p>
  
  <p>We have the same setup for other projects and it works perfectly well, so I don't really get what I miss. Beside what is inside the "<em>Classes</em>" directory, everything works fine.</p>
  
  <p>Another thing I spotted, as it was suggested by <em>Claus Due</em> down below, is I get an error saying the class is not found if I try to do something like so:</p>
  
  <pre><code>use Domain\Website\ViewHelpers\String;
  $foo = new IdFromTitleViewHelper();
  print_r($foo);
  </code></pre>
  
  <p>However, it works if I do the following thing (for example):</p>
  
  <pre><code>include __DIR__ .'/../../../Classes/ViewHelpers/String/IdFromTitleViewHelper.php';
  $foo = new Domain\Website\ViewHelpers\String\IdFromTitleViewHelper();
  print_r($foo);
  </code></pre>
  
  <p>I also noticed that my extension is completely missing in the files "<em>autoload_classmap.php</em>", "<em>autoload_psr4.php</em>" and "<em>autoload_static.php</em>" at the root of the installation ("<em>./vendor/composer</em>"). Even if I composer <code>dump-autoload -o</code>, it does not appear. It is also not referenced in the "<em>installed.json</em>" file and in the "<em>composer.lock</em>" file.</p>
  
  <p>Does anyone have a clue about this problem? Any help would be much appreciated.</p>
  
  <p>Many thanks in advance.</p>
  
  <p>Best regards,</p>
  
  <h2>SOLUTION</h2>
  
  <p>Just because I was desperate, I tried to redo</p>
  
  <pre><code>rm -rf vendor
  rm -rf htdocs\typo3conf\ext
  composer clearcache
  composer install
  </code></pre>
  
  <p>for the nth time and... problem solved!</p>