尽管已正确引用,但未找到类

时间:2013-10-07 19:04:59

标签: php symfony

我必须失明。我无法弄清楚为什么,但我得到一个例外:

FatalErrorException: Error: Class 'BConway\WebsiteBundle\Form\Type\BusinessType' not found

以下是我的文件:

<?php

namespace BConway\WebsiteBundle\Controller;

use BConway\WebsiteBundle\Document\Business;
use BConway\WebsiteBundle\Form\Type\BusinessType;
use Doctrine\Common\Util\Debug;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class BusinessController extends Controller
{
    public function newAction(Request $request)
    {
        $formBusiness = $this->createForm(new BusinessType(), new Business());
        $formBusiness->handleRequest($request);

        return $this->render('BConwayWebsiteBundle:Business:new.html.twig', array(
            'formBusiness' => $formBusiness->createView(),
            'action'       => 'create',
        ));
    }
}

<?php
// src/BConway/WebsiteBundle/Form/Type/BusinessType.php
namespace BConway\WebsiteBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use BConway\WebsiteBundle\Form\Type\AddressType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class BusinessType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('ad', 'string')
            ->add('address', new AddressType())
            ->add('claimed', 'boolean')
            ->add('coupons', 'string')
            ->add('dateCreated', 'date')
            ->add('dateModified', 'date')
//            ->add('hours', 'collection', array('type' => new HoursType()))
            ->add('name', 'string')
            ->add('organization', 'string')
            ->add('permanentlyClosed', 'string')
            ->add('phone', 'string')
//            ->add('services', 'collection', array('type', new ServiceType()))
            ->add('tags', 'collection')
            ->add('website', 'string');
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'BConway\WebsiteBundle\Document\Business',
        ));
    }

    public function getName()
    {
        return 'business';
    }
}

我没看到什么?我一直盯着这些文件一个小时,我找不到问题。

我为这一部分道歉但是我不会允许我提交我的问题,因为太多的是代码与文本....所以我只是填补空间。

1 个答案:

答案 0 :(得分:0)

我在MyBundle \ Form中有FormType.php文件,我错过了创建MyBundle \ Form \ Type文件夹。