我的项目中有两个路由文件:
event.yml
user.yml
我正在尝试向event.yml文件添加新路由:
registro_eventos:
path: /evento
defaults: { _controller: AppBundle:Event:registroevento }
EventController.php
文件上的函数registroeventoAction是:
public function registroeventoAction(Request $request)
{
$evento = new Evento();
$form = $this->createForm(EventoType::class, $evento);
return $this->render('AppBundle:Event:registroeventos.html.twig',array(
'form' => $form->createView()
));
}
当我尝试路线时,答案是err_invalid_response
(就像路线不存在一样)。
我已经尝试将不同的路由添加到同一个文件并始终使用相同的amswer(我必须说此文件中的先前路由正常工作!)
最后我已将路线添加到user.yml
文件并且有效!
有谁知道为什么会这样?
提前感谢您的帮助!
的Arturo
添加信息:
app / config / routing.yml的内容是:
app:
resource: "@AppBundle/Resources/config/routing.yml"
prefix: /
AppBundle / Resources / config / routing.yml的内容是:
app_user:
resource: "@AppBundle/Resources/config/routing/user.yml"
prefix: /
app_event:
resource: "@AppBundle/Resources/config/routing/event.yml"
prefix: /
app_homepage:
path: /
defaults: { _controller: AppBundle:User:login }
app_candidato:
resource: "@AppBundle/Resources/config/routing/candidato.yml"
prefix: /
这是AppBundle / Resources / config / routing / event.yml的内容(此路由正常运行,但如果我添加新路由,则不会这样做)
home:
path: /home
defaults: { _controller: AppBundle:Event:index }
indice_eventos:
path: /indice_eventos
defaults: { _controller: AppBundle:Event:indice }
inscriptos_evento:
path: /inscriptos/{slugevento}
defaults: { _controller: AppBundle:Event:listadoInscriptos, slugevento:null }
inscriptos_excel:
path: /{_filename}.{_format}
defaults: { _controller: AppBundle:Event:excelInscriptos, _format: xlsx }
inicia_registro:
path: /inicia_registro
defaults: { _controller: AppBundle:Event:iniciaRegistro }
datos_personales:
path: /datos_personales
defaults: { _controller: AppBundle:Event:datosPersonales }
最后是AppBundle / Resources / config / routing / user.yml的内容
login:
path: /login
defaults: { _controller: AppBundle:User:login }
login_check:
path: /login_check
logout:
path: /logout
register:
path: /register
defaults: { _controller: AppBundle:User:register }
user_email_test:
path: /email-test
defaults: { _controller: AppBundle:User:emailTest }
methods: [POST]
user_edit:
path: /my-data
defaults: { _controller: AppBundle:User:editUser }
usuarios_list:
path: /usuarios
defaults: { _controller: AppBundle:User:usuarios }
usuarios_search:
path: /search
defaults: { _controller: AppBundle:User:search }
registro_eventos:
path: /evento
defaults: { _controller: AppBundle:Event:registroevento }
editar_evento:
path: /evento/{idevento}
defaults: { _controller: AppBundle:Event:editevento, idevento:null }
borrar_evento:
path: /delevento/{idevento}
defaults: { _controller: AppBundle:Event:deleteEvento, idevento:null }
答案 0 :(得分:0)
在文件app/config/routing.yml
中,您应该添加路由文件:
my_events:
prefix: /events
resource: "@appBundle/Resources/config/event.yml"
您可以使用"PATH/events/evento"