samuraiseoul / Essence

Type safe PHP request lifecycle framework with no magic.
Other
2 stars 0 forks source link

Routing #15

Open samuraiseoul opened 5 years ago

samuraiseoul commented 5 years ago

Default to none, use file system routing by default.

IF you want a router for path parameters, default to numeric only based on the preceding path and assume all numeric only path parts are actually ids, no developer supplied configuration will be required for this. E.G: http://www.example.com/user/1222 maps to http://www.example.com/user/index.php and the path param map will be ['userId' => 1222]. http://www.example.com/user/123/post/456/comment/789 maps to http://www.example.com/user/post/comment/index.php with the path param map of ['userId' => 123, 'postId' => 456, 'commentId'=> 789]

Then finally, custom routing based on programmer supplied path resolvers, the file system still the basic idea of routing and handling though. Something like Essence::map('user/{name}/comments', 'user/comments/index.php');

Path parameters will be a part of the RequestWrapper, maybe the request too in the StartLine's Request Target.

samuraiseoul commented 5 years ago

Also I heard htaccess is slow and meh. Specifically due to looking in every folder for htaccess.

Could there be a project that imports the endpoints and such files needed via composer to prevent moving down lots of folders? I guess it would look in ./vendor though...

Also I feel that there may be some other server or way of serving things. Java packs a server instead of calling each file, is there a way for php to do that to with a C module or something? Might be worth looking at instead of apache/nginx/fmp