IM相當新的Mac和Symfony的,一般如果我在想念任何基本知識錯誤:調用一個成員函數的get()一個非對象500內部服務器錯誤 - FatalErrorException(Symfony的)
基本上是試圖難過使用PHP類,在這裏它的下面
<?php
namespace TeamRock\ApplicationBundle\entity;
class Person{
protected $email;
protected $fullname;
public function getEmail(){
return $this->$email;
}
public function setEmail($email){
return $this->$email;
}
public function getFullname(){
return $this ->$fullname;
}
public function setFullname($fullname){
return $this -> $fullname;
}
}
?>
創建一個表單然後我有我的課
<?php
namespace TeamRock\ApplicationBundle\form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class personType extends AbstractType{
public function buildForm(FormBuilderInterface $builder, array $options){
$builder->add ('email','email')->add ('name','text')->add('submit','submit');
}
public function getName(){
return 'person';
}
}
?>
,然後主控制器上
<?php
namespace TeamRock\ApplicationBundle\Controllers\Calvin;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use TeamRock\ApplicationBundle\entity\Person;
use TeamRock\ApplicationBundle\form\PersonType;
class Homepage
{
public function __invoke(Request $request)
{
$person = new person();
$form = $this->createForm(new PersonType(), $person);
return new Response("Hello, world!", Response::HTTP_OK, array('form'=>$form->createView()));
}
}
?>
,我不斷收到錯誤是
Attempted to call method "createForm" on class "TeamRock\ApplicationBundle\Controllers\Calvin\Homepage".
500 Internal Server Error - UndefinedMethodException
任何幫助表示讚賞球員,正如我所說的即時通訊相當新的PHP和Symfony和它的一個大的學習曲線,所以任何幫助或指針讚賞
我一直都再次
感謝看着這傢伙的影片僅作參考Andrew Perkins Symfony Tutorials
任何幫助提前!
您的控制器沒有從symfony擴展任何控制器,那麼在類定義裏面沒有'createFrom' – 2015-02-24 11:20:30
也可能的類型personType類名應該是PersonType – Rooneyl 2015-02-24 11:21:09
@Rooneyl PHP類名不區分大小寫,不是嗎? – chapay 2015-02-24 11:27:30