Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2 No route found for GET/add
    text
    copied!<p>i am trying to add some value to db via entitiy (i'm studying examples). I crated a local route for createAction which is located in DefaultController. But when i try to go to page, it says no router.</p> <p>Here is my example code. How can i solve this. Thanks for help.</p> <pre><code>/*Local Routes: acme_store_homepage: pattern: /hello/{name} defaults: { _controller: AcmeStoreBundle:Default:index } acme_store_product: pattern: /add defaults: { _controller: AcmeStoreBundle:Default:create } */ /* app Routes: acme_store: resource: "@AcmeStoreBundle/Resources/config/routing.yml" prefix: / */ /* Default Controller */ &lt;?php namespace Acme\StoreBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Acme\StoreBundle\Entity\Product; use Symfony\Component\HttpFoundation\Response; class DefaultController extends Controller { public function indexAction($name) { return $this-&gt;render('AcmeStoreBundle:Default:index.html.twig', array('name' =&gt; $name)); } public function createAction() { $product = new Product(); $product-&gt;setName("SomeProduct"); $product-&gt;setPrice("1000"); $product-&gt;setDescription("Bla bla bla."); $em = $this-&gt;getDoctrine()-&gt;getManager(); $em-&gt;persist($product); $em-&gt;flush(); return new Response('Product id: '.$product-&gt;getId()); } } //Running http://localhost/Symfony/web/app_dev.php/demo/add is throwing an exception: No route found for "GET /demo/add" //Running http://localhost/Symfony/web/app_dev.php/demo/hello/World is Fine... </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload