php - Handle AJAX requests in separated directory/files -
i want move methods controller, executed ajax request, separate folder. example create file userbundle/ajax/ajax.php
, put in file, ajax request methods.
is right approach, separate ajax requests, normal http requests? can't find examples how it. possible in symfony? must extend symfony\bundle\frameworkbundle\controller\controller
in ajax.php
file? okay, exist 2 folders in bundle ajax
, controller
, contains controllers first ajax request , second normal http request?
do know architectural pattern, problem?
i don't think there problem that, make sure define routing path correctly:
an example annotation routing:
# app/config/routing.yml app_bundle: resource: "@appbundle/controller" type: annotation prefix: / app_bundle_ajax: resource: "@appbundle/ajax" type: annotation prefix: /
i must extend symfony\bundle\frameworkbundle\controller\controller in ajax.php file?
it's not mandatory, symfony\bundle\frameworkbundle\controller\controller
provide excellent shortcuts $this->json(...);
since symfony 3.1
Comments
Post a Comment