prozrost2017-08-13 09:42:56
prozrost, 2017-08-13 09:42:56

404 when trying to do REST?

I want to make a simple REST using FosRestBundle, FosUserBundle. I wrote the routing like this:

    type:     rest
    host:     localhost
    resource: AppBundle\Controller\UserController

and registered Action in the controller
public function newUserAction()
        $user = new User();
        $form = $this->createForm(RegistrationFormType::class,$user);
        return $this->render('default/new.html.twig', array(
        'form' => $form->createView(),

Error 404 when trying to access localhost/web/newUser. Using Symfony 3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Alexander Kuznetsov, 2017-08-13

1. Check the routing, especially the annotations.
2. Stop using the production entry point and refer to app_dev.php. You may have routing problems - the cache is not rebuilt.
Refer to localhost/web/app_dev.php/newUser if you are in a dev environment

Konstantin Malyarov, 2017-08-13

Check your routing again.
You don't seem to have read the documentation.
If you have chrome: Let's move on. PCM. Translate to Russian. Reading.
If you are silent, then you did not find it. Below is the code from the official documentation:

public function newUsersAction()
    {} // "new_users"            [GET] /users/new

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question