Symfonyアプリケーションに非常に奇妙な問題があります。すべてはsymfonyの3.0.9で正常に動作しますが、3.1にアップグレードするとき(現在3.1.3を実行している)されて、私はほとんどすべてのコントローラと、次のエラーが表示されます。ここではsymfony 3.0.9から3.1.3へのアップグレード後の変なコントローラエラー
"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.1に発生し、全体アプリは3.0.9で正常に動作します。
他にもこれを見ましたか?私は3.1で発表された私のコードに構造上の問題がありますか(私はプロのコーダーではありません...)
ありがとう!
アンドレアス
アップグレード後にキャッシュをクリアしましたか?リクエストは適切に名前空間になっていますか?おそらくあなたの質問を経路定義で更新してください。問題の原因となるのは、キャッシュのクリアだけです。 – Cerad
キャッシュをクリーニングしてみます。 'bin/console cache:clear' – ciurciurek
うん。すべてを完了した。私は興味のある何かを見つけました。この問題はphp7.0でsymfony^3.1を実行すると消えます。この問題はphp> 7.0のsymfony> 3.0でのみ発生します。 – Andreas