Symfony 응용 프로그램에 이상한 문제가 있습니다. 여기 symfony 3.0.9에서 3.1.3으로 업그레이드 한 후 이상한 컨트롤러 오류가 발생했습니다.
이 오류가 발생하는 방법의 예입니다 : 3.1 (현재 3.1.3을 실행하는) 내가 거의 모든 컨트롤러와 함께 다음과 같은 오류가 업그레이드 할 때 모든 심포니 3.0.9에서 잘 작동되지만, 다음과 같이이 방법"Controller "Name_of_Controller::name_of_method" requires that you provide a value for the "$request" argument (because there is no default value or because there is a non optional argument after this one)."
/**
* This method handles add faculty
* requests
*
* @param Request $request html request
*
* @return Response html response
*
**/
public function addAction(Request $request)
{
// create a new Faculty
$faculty = new Faculty();
$faculty->setFirstname('Enter First Name');
$faculty->setLastname('Enter Last Name');
$form = $this->createForm(FacultyType::class, $faculty);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$task = $request->get('Submit');
// let see what the user wants
switch ($task) {
case 'Add':
// user wants to add
// we are setting the fullname of the object
$lname = $form->getData()->getLastname();
$fname = $form->getData()->getFirstname();
$faculty->setFullname("$lname, $fname");
$em = $this->getDoctrine()->getManager();
$em->persist($faculty);
$em->flush();
// report success
$this->addFlash('success', "The faculty member $faculty was successfully saved!");
return $this->redirectToRoute('faculty_index');
break;
case 'Cancel':
// report failure
$this->addFlash('failure', "The action was cancelled. No faculty member was saved!");
return $this->redirectToRoute('faculty_index');
}
}
return $this->render(
'faculty/add.html.twig',
[
'form' => $form->createView(),
]
);
}
는 XML 경로는 다음과 같습니다 위에서 언급 한 바와 같이
는<route id="faculty_add" path="/add" methods="GET POST">
<default key="_controller">AppBundle:Faculty:add</default>
</route>
, 단지 전체 응용 프로그램은 3.0.9에서 잘 작동, 3.1에서 발생합니다.
다른 사람이 본 적이 있습니까? 3.1에서 공개 된 코드에 구조적 문제가 있습니까? (전문적인 코더가 아닙니다 ...)
감사합니다!
안드레아스
업그레이드 후 캐시를 지우셨습니까? 요청이 제대로 네임 스페이스입니까? 어쩌면 경로 정의로 질문을 업데이트 할 수 있습니다. 캐시 지우기가 문제를 일으킬 수있는 유일한 것입니다. – Cerad
캐시를 정리하십시오. 'bin/console cache : clear' – ciurciurek
예. 모든 것을 끝냈다. 내가 관심을 가질만한 다른 것을 찾았습니다. php7.0으로 symfony^3.1을 실행할 때 문제가 사라집니다. 이 문제는 php> 7.0에서 symfony> 3.0에서만 발생합니다. – Andreas