Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8847567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:13:16+00:00 2026-06-14T12:13:16+00:00

I’m trying to update a record in my mysql database by calling the put

  • 0

I’m trying to update a record in my mysql database by calling the put method from my sencha touch 2 frontend. I’m calling this url /api/users/id but I keep getting a Symfony error:

No route found for "PUT /api/users/1

This is what I have in my routing.yml file

users:
    resource: "Acme\MainBundle\Controller\UsersController"
    prefix:   /api
    type:     rest

Also, I have the putUsersAction setup in my User*s*Controller

public function putUsersAction($id, Request $request)
{
    $values['birthdate'] = $request->get('birthdate');
    $values['clubid'] = $request->get('clubid');

    $em = $this->getDoctrine()->getEntityManager();

    $user = $this->getDoctrine()
        ->getRepository('AcmeMainBundle:User')
        ->find($id);

    $club = $this->getDoctrine()
        ->getRepository('AcmeMainBundle:Club')
        ->find($values['clubid']);

    $user->setBirthdate($values['birthdate']);
    $user->addClub($club);

    $em->flush();

    $view = View::create()
        ->setStatusCode(200)
        ->setData($user);

    return $this->get('fos_rest.view_handler')->handle($view);
}

Why is Symfony telling me there’s no PUT /api/users/id route?

EDIT 1: router:debug output

[router] Current routes
Name                     Method Pattern
_wdt                     ANY    /_wdt/{token}
_profiler_search         ANY    /_profiler/search
_profiler_purge          ANY    /_profiler/purge
_profiler_info           ANY    /_profiler/info/{about}
_profiler_import         ANY    /_profiler/import
_profiler_export         ANY    /_profiler/export/{token}.txt
_profiler_phpinfo        ANY    /_profiler/phpinfo
_profiler_search_results ANY    /_profiler/{token}/search/results
_profiler                ANY    /_profiler/{token}
_profiler_redirect       ANY    /_profiler/
_configurator_home       ANY    /_configurator/
_configurator_step       ANY    /_configurator/step/{index}
_configurator_final      ANY    /_configurator/final
get_users                GET    /api/users.{_format}
post_users               POST   /api/users.{_format}
get_clubs                GET    /api/clubs.{_format}
post_clubs               POST   /api/clubs.{_format}
put_users                PUT    /api/users.{_format}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:13:17+00:00Added an answer on June 14, 2026 at 12:13 pm

    At first you should debug your routing and see if the route is being registered correctly. Your posted routing snipped lacks correct intendation. It should read:

    user:
        resource: "Acme\MainBundle\Controller\UserController"
        prefix:   /api
        type:     rest
    

    Afterwards you can debug your routing with the console command:

    php app/console router:debug
    

    Furthermore you can use grep ( Unix ) or findstr ( Windows ) to search the output for your route:

    php app/console router:debug | grep /api
    

    or

    php app/console router:debug | findstr /api
    

    Next make sure for the automatic routing of FOSRestBundle to work as expected to name your controller User*s*Controller and the file User*s*Controller.php.

    See: FOSRestBundle Documentation

    Please note that you have forgotten to call persist($user) before flushing and that you cannot call flush on your User entity but on your EntityManager. See my example below.

    You can slim down your controller a lot by using DependencyInjection , the symfony2 ParamConverter, implicit resource name definition and the @View Annotation provided by the FOSRestBundle.

    Your Controller would then read something like this:

    <?php
    
    namespace Acme\MainBundle\Controller;
    
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    use Symfony\Component\HttpFoundation\Request;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
    use JMS\DiExtraBundle\Annotation as DI;
    use Acme\MainBundle\Entity\User;
    use FOS\RestBundle\Controller\Annotations\View;
    
    /**
     * @DI\Service
     */
    class UserController
    {
    
        /** @DI\Inject("doctrine.orm.entity_manager") */
        private $em;
    
        // ...
    
        /**
         * @View()
         */
        public function putAction(User $user, Request $request)
        {
    
            $club = $this->em
                ->getRepository('AcmeMainBundle:Club')
                ->findOneById($request->get('clubid'));
    
            $user
                ->setBirthdate($request->get('birthdate')
                ->addClub($club);
    
            // you should add some validation here 
    
            $this->em->persist($user);
            $this->em->flush();
    
            return $user;
       }
    
       // ...
    }
    

    Explanations:

    I have used the JMSDiExtraBundle’s annotations. You need this bundle to make them work.

    Otherwise you should declare your controller as a service and inject the EntityManager manually ( for example in your bundle’s Resources/config/services.xml ) in the service container.

    Declare your controller as Service with @DI\Service annotation.

    Inject your EntityManager here to be be able to access it throughout the class with $this->em with the @DI\Inject annotation.

    Use FOSRest’s @View annotation.
    Don’t forget to set sensio_framework_extra.view: { annotations: false } before using this if you have the SensioFrameworkExtraBundle’s in your application.

    Make sure you have return $this; at the end of your User entity’s setBirthdate(…) and addClub(…) functions.

    Please not that i have used [JMSDiExtraBundle’s property injection][3] in the example.
    The bundle has to be installed in order to be used.

    You might be able to slim down the controller further by using the NoxLogicMultiParamBundle.

    I cannot post more than 2 links because im new over here…

    • please look for the following resources on google:
    • NoxLogicMultiParamBundle
    • FOSRestBundle documentation
    • JMSDiExtraBundle documentation
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.