commander icon indicating copy to clipboard operation
commander copied to clipboard

Add description text to Route

Open davidwdan opened this issue 7 years ago • 2 comments

It would be nice to have the ability to add some optional description text to a route.

Something like:

$router->add('test', function () {
    //do something
})->addDescription('This is a description');

OR

$router->add('test', function () {
    //do something
}, 'This is a description');

davidwdan avatar Nov 06 '16 20:11 davidwdan

Thanks for opening this ticket :+1: I understand where you're coming from as I have faced the same issue when integrating this into some bigger projects.

I'm currently undecided because I'm not sure what the best interface would look like, given we don't really work with these texts, unlike for example Symfony Console. Do we need a "description", "short text", "long text" etc.?

In the meantime, I've applied the following workaround when I integrated this into another project: https://github.com/clue/psocksd/blob/a922d8beeff7b98a99ac50e910cd95b60a318218/src/Command/Via.php#L25 PHP allows you to set arbitrary additional public properties, so these can be used to attach any kind of information you need. (Note I'm not saying this is the best solution, but it kind of works for now)

I'd love to hear some more thoughts on this :+1:

clue avatar Nov 07 '16 14:11 clue

I think that the solution you suggested will work for my purposes.

davidwdan avatar Nov 07 '16 21:11 davidwdan