I've recently deployed my Symfony project to a production environment. Everything is loading except the .getJSON jquery function. This returns a 404 error. Now the strange part is that it works localy.
This is the code.
Jquery:
$.getJSON('/ClientThisYear', function(response) {
Routing:
app:
resource: "@AppBundle/Controller"
type: annotation
AppBundle/Controller:
/**
* @Route("/ClientThisYear")
*/
public function ClientThisYear()
{
$em = $this->getDoctrine()->getManager();
$ClientStats = $em->getRepository('ClientBundle:Client')
->ClientStats();
$ClientArray = array();
foreach($ClientStats[0] as $Arr)
{
$ClientArray[] = $Arr;
}
$Return = json_encode($ClientArray);
return new Response($Return,200,array('Content-Type'=>'application/json'));
}
So it worked for a while but after a while it started returning a 404 error.
What i've tried is:
- Clearing the cache.
- Deployed it again from local.
Error log :
[2015-12-30 14:50:43] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /ClientThisYear" (from "http://example.nl/web/admin")" at /home/**/**/var/cache/prod/classes.php line 2377 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /ClientThisYear\" (from \"http://example.nl/web/admin\") at /home/**/**/var/cache/prod/classes.php:2377, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): at /home/**/**/var/cache/prod/appProdUrlMatcher.php:255)"} []
Can someone please help me with this
http://localhost/myapp/ClientThisYearvshttp://mywebsite/ClientThisYear. Can you invoke the path via browser at all? What does the log say about error? Or maybe production does not havemod_rewriteenabled?