0

I created a bundle in symfony4 following the symfony 4 bundle docs

my bundle class is this:

<?php
namespace Infrastructure\Delivery\Frontend\TodoBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class TodoBundle extends Bundle
{
}

and I enabled the bundle in config/bundles.php like this:

<?php

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
    Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
    Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
    Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
    Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
    Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
    Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
    Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
    Infrastructure\Delivery\Frontend\TodoBundle\TodoBundle::class =>['all' => true]
];

when I try to run, the symfony server shows me this error:

(1/1) ClassNotFoundException

Attempted to load class "TodoBundle" from namespace "Infrastructure\Delivery\Frontend\TodoBundle".
Did you forget a "use" statement for another namespace?

I checked over the files many times but i not found where the error is. Anybody can help me?

thanks

bcg
  • 261
  • 1
  • 4
  • 26
  • Checks your `composer.json` file `autoload` section. – yceruto Aug 18 '18 at 12:47
  • `"autoload": { "psr-4": { "App\\": "src/" } }, "autoload-dev": { "psr-4": { "App\\Tests\\": "tests/" } },` – bcg Aug 18 '18 at 14:52
  • it seems is ok no? – bcg Aug 19 '18 at 10:12
  • hey try changing Infrastructure\Delivery\Frontend\TodoBundle\TodoBundle::class =>['all' => true] to Infrastructure\Delivery\Frontend\TodoBundle::class =>['all' => true] As you want to load all the classes from the TodoBundle namespace. – Dennis de Best Jan 04 '19 at 08:42

0 Answers0