所以我试图发出宁静的网络请求,但是,我可能把它配置错了,我似乎无法修复。
我有这个想法。
/companies GET -> index method
/companies POST -> add post method
/companies/1 GET -> show method
/companies/1 POST -> edit post method
这是我尝试过的
"router" => [
"routes" => [
"companies" => [
"type" => "segment",
"options" => [
"route" => "/companies[/:id]",
"constraints" => [
"id" => "[0-9]*",
],
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "index",
],
],
"may_terminate" => true,
"child_routes" => [
"companiesIndex" => [
"type" => "segment",
"options" => [
"verb" => "GET",
"route" => "/companies",
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "index"
],
],
],
"companiesAddPost" => [
"type" => "segment",
"options" => [
"verb" => "POST",
"route" => "/companies",
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "add"
],
],
],
"companiesShow" => [
"type" => "segment",
"options" => [
"verb" => "GET",
"route" => "/companies/:id",
"constraints" => [
"id" => "[0-9]*",
],
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "show"
],
],
],
"companiesEditPost" => [
"type" => "segment",
"options" => [
"verb" => "PATCH",
"route" => "/companies/:id",
"constraints" => [
"id" => "[0-9]*",
],
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "edit"
],
],
],
],
],
/companies
索引方法有效。不确定邮政。但是每当我尝试请求它时,/companies/1
它仍然显示索引方法。出了什么问题,我应该如何解决。