Bartosz Brożek
Bartosz Brożek

Reputation: 169

Symfony 3.2.4 wildcard routing causes 100% cpu utilization

I have very strange problem:

I have two routes: First one comes with wildcard:

/**
 * @Route("/test/{test}", name="test")
 * @param type $route
 */
public function testAction(Request $request, $test) {

    return $this->render('resource/showResource.html.twig', [
                'test' => $test
    ]);
}

Second one is without wildcard:

/**
 * @Route("/test", name="test")
 * @param type $route
 */
public function testAction(Request $request) {

    return $this->render('resource/showResource.html.twig', [
                'test' => 'something'
    ]);
}

The problem is when I'm running first one (http://localhost/app_dev.php/test/1) my CPU utilization reaches almost 100% (process: httpd.exe => Apache HTTP Server.

There is no such a problem with second one.

What thing could be causing this?

Upvotes: 0

Views: 116

Answers (3)

Bartosz Brożek
Bartosz Brożek

Reputation: 169

Problem solved: in file base.html.twig I had not working lines like this:

    <script src="../vendors/jquery/dist/jquery.min.js"></script>

Right now I am using assets for them and everything works like a charm.

Thanks for everyones effort! :)

Upvotes: 1

Maulik Savaliya
Maulik Savaliya

Reputation: 1260

Try as below may be it will help you:

/**
 * @Route("/test/{test}", name="test", requirements={"test": "\d+"})
 * @param type $route
 */
public function testAction(Request $request, $test) {

    return $this->render('resource/showResource.html.twig', [
            'test' => $test
    ]);
}

Check more details on http://symfony.com/doc/current/routing.html#adding-wildcard-requirements

Upvotes: 0

Annemieke Buijs
Annemieke Buijs

Reputation: 80

/**
 * @Route("/test/{test}", name="test")
 */
public function testAction($test) {

    return $this->render('resource/showResource.html.twig', [
       'test' => $test
    ]);
}

Upvotes: 0

Related Questions