0
votes

I am trying to access a POST route which is currently working locally but doesn’t work once deployed to the production server. I've removed the name of the app and replaced with XXX in the following. I've run out of ideas and I think I've tried everything posted here.

We have a very similar POST only route which is working fine, but from a previous deployment.

I'm trying to access the route www.XXX.com/api/convert_mov

my routing.yml

XXX_api_convert:
    path:     /api/convert_mov
    defaults: { _controller: XXXPartnerBundle:API:convert }
    methods:  [POST]

php app/console router:debug | grep api returns

XXX_api_convert POST     ANY    ANY  /api/convert_mov

I have run

php app/console cache:clear --env=prod

app/logs/prod.log shows

request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "POST /api/convert_mov"" at /var/www/XXX/ppp/releases/20150903102317/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 144 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code: 0): No route found for \"POST /api/convert_mov\" at /var/www/XXX/ppp/releases/20150903102317/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php:144, Symfony\Component\Routing\Exception\ResourceNotFoundException(code: 0): at /var/www/XXX/ppp/releases/20150903102317/app/cache/prod/appProdUrlMatcher.php:738)"} []

Even after warming up the cache I can see this in appProdUrlMatcher.php

// XXX_api_convert
                if ($pathinfo === '/api/convert_mov') {
                    if ($this->context->getMethod() != 'POST') {
                        $allow[] = 'POST';
                        goto not_XXX_api_convert;
                    }

                    return array (  '_controller' => 'XXX\\PartnerBundle\\Controller\\APIController::convertAction',  '_route' => 'XXX_api_convert',);
                }
                not_XXX_api_convert:

            }
1
do you have any concurrent route?thesearentthedroids
Good suggestion. I've double checked and the route and name are unique.RonnyKnoxville
Maybe that route is on dev only? run php app/console router:debug --env=prod | grep apimalcolm
Unfortunately it also shows there correctly, even with the env=prod flag. I can even see the code in the appProdUrlMatcher.php in the prod cache after warming it upRonnyKnoxville

1 Answers

0
votes

I managed to resolve this problem with a different deploy script. The new script performed some extra tasks on the server including restarting PHP which may have been the answer.

Clearing the cache for the prod environment with debug false
Stopping php-fpm-5.5:                                      [  OK  ]
Starting php-fpm-5.5:                                      [  OK  ]
Nothing to update - your database is already in sync with the current entity metadata.
Installing assets as hard copies.
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
Installing assets for XXX\PartnerBundle into web/bundles/XXXpartner
Installing assets for Sonata\CoreBundle into web/bundles/sonatacore
Installing assets for Sonata\AdminBundle into web/bundles/sonataadmin
Installing assets for FOS\JsRoutingBundle into web/bundles/fosjsrouting
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
Running XXX:migrate
XXX:migrate - done