Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8336211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:54:49+00:00 2026-06-09T03:54:49+00:00

Ok, I’ve been at this for two hours now and I see some other

  • 0

Ok, I’ve been at this for two hours now and I see some other people have had this error, but I can’t seem to match their causes/resolutions with mine.

Fatal error: require() [function.require]: Cannot redeclare class companycontroller in /var/www/biztv_symfony/vendor/symfony/src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php on line 55

The terminal gives a better error message pointing me to the end clause of the actual class that it reports having trouble with (trying to redeclare).

If I remove or rename the file companyController.php it throws a Symfony2 error saying that the it went looking for the class but didn’t find it where it was expected.

If I put the file back in its place, apache throws a php error saying that the class companyController can’t be redeclared.

I only have it once?!

Here is the entire class… if anyone has patience to try and help me out…

<?php

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use BizTV\BackendBundle\Entity\company;
use BizTV\BackendBundle\Form\companyType;

/**
 * company controller
 *
 */

class companyController extends Controller
{
    /**
     * Lists all company entities.
     *
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getEntityManager();

        $entities = $em->getRepository('BizTVBackendBundle:company')->findAll();

        return $this->render('BizTVBackendBundle:company:index.html.twig', array(
            'entities' => $entities
        ));
    }

    /**
     * Finds and displays a company entity.
     *
     */
    public function showAction($id)
    {
        $em = $this->getDoctrine()->getEntityManager();

        $entity = $em->getRepository('BizTVBackendBundle:company')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find company entity.');
        }

        $deleteForm = $this->createDeleteForm($id);

        return $this->render('BizTVBackendBundle:company:show.html.twig', array(
            'entity'      => $entity,
            'delete_form' => $deleteForm->createView(),

        ));
    }

    /**
     * Displays a form to create a new company entity.
     *
     */
    public function newAction()
    {
        $entity = new company();
        $form   = $this->createForm(new companyType(), $entity);

        return $this->render('BizTVBackendBundle:company:new.html.twig', array(
            'entity' => $entity,
            'form'   => $form->createView()
        ));
    }

    /**
     * Creates a new company entity.
     *
     */
    public function createAction()
    {
        $entity  = new company();
        $request = $this->getRequest();
        $form    = $this->createForm(new companyType(), $entity);
        $form->bindRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getEntityManager();
            $em->persist($entity);
            $em->flush();

            /* Create adminuser for this company to go along with it */
            $userManager = $this->container->get('fos_user.user_manager');
            $user = $userManager->createUser();

            //make password (same as username)
            $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); //get encoder for hashing pwd later
            $tempPassword = $entity->getCompanyName(); //set password to equal company name

            //Get company
            $tempCompanyId = $entity->getId(); //get the id of the just-inserted company (so that we can retrieve that company object below for relating it to the user object later)
            $tempCompany = $em->getRepository('BizTVBackendBundle:company')->find($tempCompanyId); //get the company object that this admin-user will belong to

            $user->setUsername($entity->getCompanyName() . "/admin"); //set username to $company/admin
            $user->setEmail('admin.'.$entity->getCompanyName().'@example.com'); //set email to non-functioning (@example)
            $user->setPassword($encoder->encodePassword($tempPassword, $user->getSalt())); //set password with hash
            $user->setCompany($tempCompany); //set company for this user            
            $user->setConfirmationToken(null); //we don't need email confirmation of account
            $user->setEnabled(true); //without a confirmation token, we of course also need to flag the account as enabled manually
            $user->addRole('ROLE_ADMIN');

            $userManager->updateUser($user);

            return $this->redirect($this->generateUrl('company_show', array('id' => $entity->getId())));

        }

        return $this->render('BizTVBackendBundle:company:new.html.twig', array(
            'entity' => $entity,
            'form'   => $form->createView()
        ));
    }

    /**
     * Displays a form to edit an existing company entity.
     *
     */
    public function editAction($id)
    {
        $em = $this->getDoctrine()->getEntityManager();

        $entity = $em->getRepository('BizTVBackendBundle:company')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find company entity.');
        }

        $editForm = $this->createForm(new companyType(), $entity);
        $deleteForm = $this->createDeleteForm($id);

        return $this->render('BizTVBackendBundle:company:edit.html.twig', array(
            'entity'      => $entity,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }

    /**
     * Edits an existing company entity.
     *
     */
    public function updateAction($id)
    {
        $em = $this->getDoctrine()->getEntityManager();

        $entity = $em->getRepository('BizTVBackendBundle:company')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find company entity.');
        }

        $editForm   = $this->createForm(new companyType(), $entity);
        $deleteForm = $this->createDeleteForm($id);

        $request = $this->getRequest();

        $editForm->bindRequest($request);

        if ($editForm->isValid()) {
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('company_edit', array('id' => $id)));
        }

        return $this->render('BizTVBackendBundle:company:edit.html.twig', array(
            'entity'      => $entity,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }

    /**
     * Deletes a company entity.
     *
     */
    public function deleteAction($id)
    {
        $form = $this->createDeleteForm($id);
        $request = $this->getRequest();

        $form->bindRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getEntityManager();
            $entity = $em->getRepository('BizTVBackendBundle:company')->find($id);

            if (!$entity) {
                throw $this->createNotFoundException('Unable to find company entity.');
            }

            $em->remove($entity);
            $em->flush();
        }

        return $this->redirect($this->generateUrl('company'));
    }

    private function createDeleteForm($id)
    {
        return $this->createFormBuilder(array('id' => $id))
            ->add('id', 'hidden')
            ->getForm()
        ;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:54:50+00:00Added an answer on June 9, 2026 at 3:54 am

    So, turns out that was a clumpsy typo by moi there.

    But for anyone else who runs into this error message in Symfony2:

    Fatal error: require() [function.require]: Cannot redeclare class…

    Here is a hint: check if you have accidentally deleted or typo:ed the namespace in the file that contains the definition of the class that php claims it is trying to re-define.

    The php error message doesn’t really give you a clue to look for that… =)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
This could be a duplicate question, but I have no idea what search terms
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.