I tried Kevin Bond's Solution on this question. It works fine when using the application in the browser but throws the following exception on console commands. I triplechecked my syntax for typos... The code is exactly the same as in the above linked question. The only thing I changed is the bundle name.
$ php app/console
<?
// src/AppBundle/DependencyInjection/Compiler/ValidatorPass.php
namespace AppBundle\DependencyInjection\Compiler;
use Symfony\Component\Finder\Finder;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
class ValidatorPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$validatorBuilder = $container->getDefinition('validator.builder');
$validatorFiles = array();
$finder = new Finder();
foreach ($finder->files()->in(__DIR__ . '/../../Resources/config /validation') as $file) {
$validatorFiles[] = $file->getRealPath();
}
$validatorBuilder->addMethodCall('addYamlMappings', array($validatorFiles));
}
}
[RuntimeException]
The autoloader expected class "AppBundle\DependencyInjection\Compiler\ValidatorPass"
to be defined in file "/home/mt/devel/netsite/phpprojekte/circle8/events/src/AppBundle/DependencyInjection/Compiler/ValidatorPass.php".
The file was found but the class was not in it, the class name or namespace probably has a typo.
Exception trace:
() at /.../vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:186
Symfony\Component\Debug\DebugClassLoader->loadClass() at n/a:n/a
spl_autoload_call() at /.../src/AppBundle/AppBundle.php:17
AppBundle\AppBundle->build() at /.../app/bootstrap.php.cache:2632
Symfony\Component\HttpKernel\Kernel->prepareContainer() at /.../app/bootstrap.php.cache:2611
Symfony\Component\HttpKernel\Kernel->buildContainer() at /.../app/bootstrap.php.cache:2564
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /home/.../app/bootstrap.php.cache:2344
Symfony\Component\HttpKernel\Kernel->boot() at /.../vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /.../vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /.../app/console:27
I tried any way of debugging I could imagine. Please help. Only thing I can do for now is commenting out the call in my AppBundle.php when using console and commenting it back in when using the browser.
- The user and the file permissions don't seem to matter.
- Emptying the cache does not help.
Things tried so far:
Fix permissions of class
$ sudo chmod -R 777 src/AppBundle/DependencyInjection/ $ sudo -u daemon php app/console cache:clear --env=dev
=> same error.Delete cache & try to warmup
$ sudo rm -rf app/cache/* $ sudo chmod 777 app/cache $ sudo app/console cache:warmup
=> same error.