AutoRoute icon indicating copy to clipboard operation
AutoRoute copied to clipboard

Add tip for handling middle URL parameters

Open joeySchentrup opened this issue 8 months ago • 0 comments

This in reference to this issue: https://github.com/pmjones/AutoRoute/issues/16

After doing some prototyping and thinking, I don't think this is a bug but a good design choice. Not allowing implicit url parameters makes the location of the parameter in the url clearer. If subdirectories were able to declare url parameters in the url earlier than their location in the url, the location of the path variable then could vary.

For example, for the class

namespace Project\Http\Photo\Edit;

class GetPhotoEdit // parent: GetPhoto
{
    public function __invoke(int $photoId)
    {
        // ...
    }
}

If there was no subclass Project\Http\Photo\GetPhoto, we would not know if $photoID was here GET /photo/$photoID/edit or GET /photo/edit/$photoID or both. Seems like a bad trade off.

Therefore, this PR is just a readme update to make it more clean the "parent" class is required if using an in the middle path variable.

joeySchentrup avatar Apr 22 '25 19:04 joeySchentrup