AnchovyLegend
AnchovyLegend

Reputation: 12537

Creating a path for a php file generates path not found error

When I try to create a path variable:

{% block jquery %} 
      <script>var url = "{{ path('bundles/foo/ajax/widb-get-data.php') }}";</script>
{% endblock %}

I get the following error:

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "FooBundle:Default:myfile.php" as such route does not exist.")

Upvotes: 0

Views: 79

Answers (1)

0x1gene
0x1gene

Reputation: 3458

I recommend you to use FOSJsRoutingBundle

you can then do :

<script>
    var url = Routing.generate('route_id', /* your params */);
</script>

Note that you are calling a route not a file

In order to call a route declared in your controller by routing.generate, be sure to expose it before :

/**
 * @Route("/foo/{id}/bar", name="my_route_to_expose", options={"expose"=true})
 */
public function exposedAction($foo)

Upvotes: 1

Related Questions