http-router icon indicating copy to clipboard operation
http-router copied to clipboard

Examples how to use this router needed

Open MekDrop opened this issue 8 months ago • 11 comments

I have a project that uses the v2 router. Now, I’ve decided to upgrade it. I tried to figure it out, but I can’t say I fully understand how it should be used.

The docs don’t explain how to create a router instance or register routes at all.

MekDrop avatar Jun 18 '25 14:06 MekDrop

Hi! I am on vacation right now, but I think we could resolve this issue later...

fenric avatar Jun 23 '25 16:06 fenric

Thanks for the response! Bad timing on my part... Anyway, have a great vacation! ^_^

MekDrop avatar Jun 23 '25 19:06 MekDrop

any updates? :/

MekDrop avatar Sep 12 '25 11:09 MekDrop

@MekDrop Hi!

I’ve put together a small demo, but I suspect you might be looking for something more. Could you tell me how you plan to use the router? Do you want to get the most out of it, or do you have a very specific use case in mind?

Feel free to ask me any questions, describe your scenario, or simply say you need “the full power” — and I’ll prepare a demo tailored to you. If you want the full feature set, the router is almost like a lightweight framework, and the result could look something like this: https://github.com/sunrise-php/awesome-skeleton

Any questions are welcome — I’m happy to help, I just need to understand exactly what you need.

And yes, I agree that the documentation isn’t great right now. There is some documentation here: https://dev.sunrise-studio.io/

…but it’s mostly focused on awesome-skeleton, since that’s how I usually structure my projects. Unfortunately, I can’t write complete documentation for every aspect of the router right this moment — that’s on the roadmap — but I can definitely help you one-on-one and answer any specific questions you have.

fenric avatar Sep 13 '25 22:09 fenric

@MekDrop https://github.com/fenric/sunrise-router-demo

fenric avatar Sep 13 '25 22:09 fenric

 php -S localhost:8080 public/index.php
curl http://localhost:8080/api/v1/ping

fenric avatar Sep 13 '25 22:09 fenric

Thanks! I was mostly confused how to register controller paths. I think I get it now.

That package that I plan to update is imponeer/smarty-sunrise-http-router. I hope later reuse for CMS where I'm involved (I still not very good with your v3 but v2 was one of easiest and powerful web routers that I have seen, so that's why)

MekDrop avatar Sep 15 '25 10:09 MekDrop

@MekDrop https://habr.com/ru/articles/891048/

Hey! I once wrote an article for the Russian-speaking community — feel free to use a translator. I think this article is a great example: it shows how to launch a project from scratch using some features of the Sunrise ecosystem. Thanks a lot for your kind words, I really appreciate it!

fenric avatar Nov 29 '25 14:11 fenric

@MekDrop https://dev.sunrise-studio.io/docs/reference/routing-annotations

In version 3 everything is configured via annotations (attributes). You can check them out here ☝️

fenric avatar Nov 29 '25 14:11 fenric

@MekDrop https://dev.sunrise-studio.io/docs/reference/router

In the context of your task and your initial question, take a look here ☝️

fenric avatar Nov 29 '25 15:11 fenric

@MekDrop https://dev.sunrise-studio.io/

You can click through the resource above ☝️, I’m trying to document Sunrise Solutions, but it takes a lot of time. Don’t hesitate to ask questions if something is unclear, and sorry for the response delays!

fenric avatar Nov 29 '25 15:11 fenric