bramus / bramus/router

Redirect to another route

Open
#143 4 comments 1 reaction 0 assignees View on GitHub
feature request
Dominant language
PHP
Stars
1.1k
Forks
236
PR merge metrics
No merged PRs in 30d

Description

Hey, nice library!

I have been stuck finding an answer.

What I Want:
```php
$router->get('/([a-z0-9_-]+)', function($slug) {
// Code to find the id
$router->callRoute(...); // Some way to call the other route, giving the id as parameter
});

$router->get('/(\d+)', function($id) {
// Code
});
```

What I did so far:
```php
function perId($id) {
// Code
}

$router->get('/([a-z0-9_-]+)', function($slug) {
// Code to find the $id
perId($id);
});

$router->get('/(\d+)', function($id) {
perId($id);
});
```

I don't know if I can accomplish the same with the `before()` function
Please give me your opinion

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the router's route-dispatch behavior and the documented before() hook. Determine whether the requested route-to-route handoff is supported or needs a defined API, including how parameters should be passed. Done means the behavior and its expected usage are clearly specified and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.