-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extends Controller Index optional parameter NOT ALLOWED #78
Comments
Hi, I know that your question was some months back, but I wonder if this might help:
The output should be:
|
Hi, $router->post("/users", [UsersController::class, "postIndex"]);
$router->get("/users", [UsersController::class, "getIndex"]);
$router->get("/users/{id:i}?", [UsersController::class, "getIndex"]);
$router->put("/users", [UsersController::class, "putIndex"]);
$router->delete("/users", [UsersController::class, "deleteIndex"]);
$router->delete("/users/{id:i}?", [UsersController::class, "deleteIndex"]); I will create an auto register method to avoid multi line spamming for each controller |
Hello everyone,
I'm having an issue using an extends controller with optional parameter for the index
I would like to create these 2 routes for my api
If I do it without a controller it works
$router->get("/users", function() { return "get all users"; });
$router->get("/users/{id:i}?", function($id = null) { return "get user id = $id"; });
Now with a controller
TEST 1
$router->controller("/users", "UsersController");
With a
public function getIndex($pId = null)
TEST 2
Trying with the following route now
$router->controller("/users/{id:i}?", "UsersController");
With a
public function getIndex($pId = null)
TEST 3
I need to add this method for both routes to work
public function anyIndex($pId = null)
Why the first test don't work?
Did I miss something ?
Is this a bug ?
Thx for answers :)
Edit :
After some others tests
TEST 2 work directly from extends controller but not if defined in base controller
The text was updated successfully, but these errors were encountered: