php-mvc icon indicating copy to clipboard operation
php-mvc copied to clipboard

Created generic handler for routes with one or more parameters

Open WKnak opened this issue 5 years ago • 4 comments

Created a generic handler for one or more parameters to avoid need to create each method a route in the application. Need to check for security (special characters).

WKnak avatar Nov 19 '20 09:11 WKnak

Thank you for the pull request @WKnak - I'll look into it. At the moment though I'm working on a major update that will change the way the framework works, so I'll take a look at your code but I don't want to update this version of the framework at the moment. Thanks!

daveh avatar Nov 19 '20 11:11 daveh

Ooooo I look forward to this major update. Any idea when it's gonna be available/if it is available somewhere else to see? Thanks :)

jackttcoms avatar Dec 02 '20 03:12 jackttcoms

@jackttcoms sorry no idea at the moment when it'll be available (current situation affecting things a bit!) - as soon as I can though!

daveh avatar Dec 02 '20 11:12 daveh

can't we add a generic route like this?

# /public/index.php
- - - - - - - - - - 
/**
 * Routing
 */
$router = new Core\Router();
// ...
// generic route -> "example.com/item" routes to "App\Item\indexAction"
$router->add('{controller}', ['action' => 'index']);
// ...
$router->dispatch($_SERVER['QUERY_STRING']);

Passing through arguments to the controller functions like this is a nice idea though. Twig escapes them when it echos them into/onto your page so I don't see a problem there

Rasalas avatar Apr 16 '22 08:04 Rasalas