我得到這個錯誤,因爲這個,我也瘋了。 我正在使用Symfony 3.2.2框架和Autoloader聲稱找到該文件,但該類不在其中,類名或命名空間可能有錯字。Symfony,Autoloader類不在其中
堆棧跟蹤
throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
}
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
}
if (self::$caseCheck) {
$real = explode('\\', $class.strrchr($file, '.'));
這就是我的BookType.php;
<?php
namespace Bookkeeeper\ManagerBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class BookType extends AbstractType{
public function buildForm(FormBuilderInterface $builder, array $options){
$builder->add('title')->add('description')->add('pages');
}
public function setDefaultOptions(OptionsResolverInterface $resolver){
$resolver->setDefault(array('data_class'=>'Bookkeeeper\ManagerBundle\Entity\Book'));
}
public function getName(){
return 'bookkeeeper_managerbundle_book';
}
}
**這是我BookController.php文件 **
<?php
namespace Bookkeeper\ManagerBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Bookkeeper\ManagerBundle\Entity\Book;
use Bookkeeper\ManagerBundle\Form\BookType;
class BookController extends Controller
{
public function indexAction(){
return $this->render('BookkeeperManagerBundle:Book:index.html.twig');
}
public function showAction($id){
return $this->render('BookkeeperManagerBundle:Book:show.html.twig');
}
public function newAction(){
$book = new Book();
$form = $this->createForm(new BookType(), $book, array (
'action' =>$this->generateUrl('book_create'),
'method'=> 'POST'
));
$form->add('submit' , 'submit' , array('label' => 'Create Book'));
return $this->render('BookkeeperManagerBundle:Book:new.html.twig', array(
'form'=>$form->createView()
));
}
public function createAction(Request $request){
}
public function editAction($id){
return $this->render('BookkeeperManagerBundle:Book:edit.html.twig');
}
public function updateAction(Request $request, $id){
}
public function deleteAction(Request $request, $id){
}
}
預計什麼樣的類? –
要在文件「/home/huseyinocal/bookkeeper/vendor/composer/../../src/Bookkeeper/ManagerBundle/Form/BookType.php」中定義的自動加載器預期類「Bookkeeper \ ManagerBundle \ Form \ BookType」。該文件已找到,但該類不在其中,類名或命名空間可能有拼寫錯誤。 –