jibe
jibe

Reputation: 645

Symfony routing annotation

I'm trying to add a new route on a controller, and I ran into a problem when using an email parameter:

use Symfony\Component\Routing\Annotation\Route;

   /**
     * @Route("/foo/{email}", methods="GET")
     *
     * @param string $email
     *
     * @return JsonResponse
     */
    public function fooAction(string $email) { 
        return JsonResponse::create('OK!');
    }

It seems that Symfony routing doesn't allow ..

Do I need to add something to make it works?

Upvotes: 0

Views: 121

Answers (4)

Juan I. Morales Pestana
Juan I. Morales Pestana

Reputation: 1147

You should solve that with a regex, trys something like this answer

Hope it helps!

Upvotes: 0

mblaettermann
mblaettermann

Reputation: 1943

You need to URL encode the email-address first?

Upvotes: 0

jibe
jibe

Reputation: 645

ok it's because I'm in a dev env, and I start the server using

php -S 127.0.0.1:8000 -t public

using symfony/web-server-bundle it works

Upvotes: 1

user3396420
user3396420

Reputation: 840

Try to end the route with '/'

@Route("/foo/{email}/", methods="GET")

Upvotes: 0

Related Questions