0
votes

Hello I dont know how to fix this bug , I searched in google but I got no solution for this bug

FatalErrorException: Error: Class 'Blogger\BlogBundle\Controller\Entity\Enquiry' not found in /home/ahmed/www/Symfony/src/Blogger/BlogBundle/Controller/PageController.php line 20

in /home/ahmed/www/Symfony/src/Blogger/BlogBundle/Controller/PageController.php line 20

namespace Blogger\BlogBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Blogger\BlogBundle\Controller\Entity\Enquiry ;
use Blogger\BlogBundle\Controller\Form\EnquiryType;

class PageController extends Controller {

    public function indexAction() {
        return $this->render('BloggerBlogBundle:Page:index.html.twig');
    }

    public function aboutAction() {
        return $this->render('BloggerBlogBundle:Page:about.html.twig');
    }
     public function contactAction() {
        $enquiry = new Enquiry();
        $form = $this->createForm(new EnquiryType(), $enquiry);
        $request = $this->getRequest();
        if ($request->getMethod() == 'POST') {
            $form->bind($request);
            if ($form->isValid()) {
                return $this->redirect($this->generateUrl('BloggerBlogBundle_contact'));
            }
        }
        return $this->render('BloggerBlogBundle:contact.html.twig', array('form' => $form->createView()));
    }

}
3

3 Answers

0
votes

Symfony by default doesn't use controller namespace for an entity classes.

Just try use Blogger\BlogBundle\Entity\Enquiry;

0
votes

typo

see the blank between semicolon at the end of the line

use Blogger\BlogBundle\Controller\Entity\Enquiry ;

0
votes

Not much information so i try to a hint

Are you sure your Entity Folder (and the namespace of it) is inside the Controller Folder/Namespace ?

Normally the entity namespace is Project\Bundle\Entity\MyEntity (same for forms and types)

In advance ... in your contactAction you need to call the flush() (and persist if its a new object) method of the entity manager before redirecting or your changes to the enquiry will not be saved.