6

I'm trying to make my website live but keep getting the same error...I've tried looking everywhere and using everyone solution with no luck.

Error

ClassNotFoundException: Attempted to load class "DestinationAppBundle" from namespace "Destination\AppBundle" in /home/dcms/public/html/dcms/apha/app/AppKernel.php line 19. Do you need to "use" it from another namespace?

AppKernel.php

    public function registerBundles()
{
    $bundles = array(
        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 Symfony\Bundle\AsseticBundle\AsseticBundle(),
        new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
        new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
        new Destination\AppBundle\DestinationAppBundle(),
        new Destination\Auth\HashInterfaceBundle\DestinationHashInterfaceBundle(),
    );

File Structure

src
    Destination
        AppBundle

Any ideas?

6
  • Are you using APC? Try flushing it. Commented Mar 13, 2014 at 16:46
  • how would you do that in php? Commented Mar 13, 2014 at 16:50
  • make sure you have DestinationAppBundle.php in live host. if it's work localy that means your project is not uploaded correctly, use rsync to make sure everything is sync (if you canuse rsync). Commented Mar 13, 2014 at 17:02
  • Already tried reuploading whole site twice Commented Mar 13, 2014 at 17:06
  • Upload a script with phpinfo(); to see if APC is installed. If it is you can try calling apc_clear_cache() to flush it. Commented Mar 14, 2014 at 10:13

6 Answers 6

5

first: check if the file src\Destination\AppBundle\DestinationAppBundle.php does exist

second: open DestinationAppBundle.php and chek if the namespace is Destination\AppBundle

third: check if the classname declaration is the same as the filename (in your case : DestinationAppBundle)

Sign up to request clarification or add additional context in comments.

Comments

4

Update composer.json like this:

"psr-4": {
    "AppBundle\\": "src/AppBundle",
    "UserBundle\\": "src/UserBundle"
},

After edit composer.json YOU MUST RUN composer dump-autoload

Comments

0

Verify in AppKernel.php the use of this class DestinationAppBundle

And the namespace in the class DestinationAppBundle

Comments

0

What is the namespace in your DestinationAppBundle.php ?

It should be :

<?php
namespace Destination\AppBundle;

Comments

0

If you are sure the namespace and service definition are right you can try:

  • Upgrade Symfony version. I had an strange issue with Symfony 2.8.11, new services added gave me a ClassNotFoundException. Upgrading to 2.8.17 solved it.

  • Try remove app/cache/* contents

  • Check if you are using a pre-generated boostrap cached file without the "--no-dev" option (composer dump-autoload --optimize --no-dev --classmap-authoritative) and launch command again.

Comments

0

Symfony uses PSR autoload.

You need to configure autoload in the composer.json file:

"autoload": {
    "psr-4": {
        "": "src/"
    },

This will include all files and folders under the \src folder

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.