Hi,
I am trying to get a type int parameter to the function indexAction of my controller but it doesn't work.
When the user goes to the url "my-app/users", I want to display the list of users whereas when the user goes to the url "my-app/users/1", I want to display the details of the user having the identifier 1.
Here is the code of my function "indexAction":
public function indexAction(int $id = null)
{
if(empty($id))
{
// Display the list of users
}
else
{
// Display the details of user
}
}
So I added a var_dump($id) to te function indexAction and the value of $id remains NULL when I go to the url "my-app/users/1".
I must go to the url "my-app/users/1/1" if I want to define correctly the value of the parameter.
Is it normal?
How can I do it without a route?