Get parameters in mount function
- Dominant language
- PHP
- Stars
- 1.1k
- Forks
- 236
- PR merge metrics
- No merged PRs in 30d
Description
My domains are structured like this to server different language versions of the same page:
`example.com/nl/page-1` and `example.com/en/page-1` for the same url in different languages.
My code looks like this:
```
$router->mount('/(\w+)', function($lang) use ($router){ // wrap in lang-var
echo $lang;
$router->get('/page-1', function() {
// code
});
$router->get('/page-2', function() {
// code
});
});
```
But it gives me the following error:
`Warning: Missing argument 1 for {closure}() in [path]/routes.php on line 13`
Is there a way to get the baseroute in a variable here?
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the warning using the routes.php example from the issue, then trace how mount invokes its callback and how nested get routes are registered. Check whether the language value can be passed through that flow, and consider the issue complete when the shown routes can access the language parameter without the missing-argument warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100