1

I keep getting the same error...I've tried of using everyone solution with no luck Error : ClassNotFoundException in AppKernel.php line 17: Attempted to load class "AppBundle" from namespace "AppBundle". Did you forget a "use" statement for another namespace?

<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AppBundle\AppBundle(),
            new OC\PlatformBundle\OCPlatformBundle(),
        ];

        if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

    public function getRootDir()
    {
        return __DIR__;
    }

    public function getCacheDir()
    {
        return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
    }

    public function getLogDir()
    {
        return dirname(__DIR__).'/var/logs';
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}
3
  • Could please share you AppBundle class as well? Also your directory structure around it! Commented Feb 1, 2016 at 10:52
  • thanks a lot my problem is resolved :) Commented Feb 1, 2016 at 18:31
  • Good to know, could you please share your solution or choose the right one below? This is important to help other people and solve this question Commented Feb 2, 2016 at 8:50

2 Answers 2

1

Please check if you have the directory AppBundle , if it does not exist remove this line from AppKernel.ph file :

new AppBundle\AppBundle(),
Sign up to request clarification or add additional context in comments.

2 Comments

it's thanks to you that everything is fine now thank you very much :)
Accept the answer if I answered yo question please :)
0

I think your AppBundle class is not (or badly) defined. You should have this in src/AppBundle/AppBundle.php:

<?php

namespace AppBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppBundle extends Bundle
{
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.