Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use this outside symfony? #96

Open
nmeri17 opened this issue Jan 11, 2023 · 2 comments
Open

Is it possible to use this outside symfony? #96

nmeri17 opened this issue Jan 11, 2023 · 2 comments

Comments

@nmeri17
Copy link

nmeri17 commented Jan 11, 2023

From the docs, it says that the server is to be configured from a "config/packages/mercure.php" file. I imagine this file will need to be booted by the symfony framework, which my project doesn't have. My own project uses a Roadrunner server, and they provide a configuration entry for triggering setup of a websocket server. I imagine it'll be convenient if there is a way to pass the roadrunner websocket url to the symfony mercure library, but without the symfony framework. Kindly correct my expected flow if it's wrong but these are the variables available to me

@dunglas
Copy link
Member

dunglas commented Jan 11, 2023

Hi, this library is totally standalone and doesn't need the rest of the Symfony framework. By the way it is used by modules targeting other frameworks, for instance Laravel: https://github.com/mvanduijker/laravel-mercure-broadcaster

You have an example of how to use this library without a framework in the README.md file of this repository.

Cheers!

@nmeri17
Copy link
Author

nmeri17 commented Jan 12, 2023

Thanks for getting back to me. The readme says I only need the mercure hub url and jwt, but the library's symfony docs advices the use of cookies. I can't access the hub without the token provider/jwt (are both to be combined or is there an undocumented provider for cookies?)

So, I've found documentation for the roadrunner broadcasting plugin. It seems to be missing authorisation capabilities that this mercure library does but I don't seem to be making much headway combining both. Nevertheless, I'll appreciate if you can clear the air regarding questions in the previous paragraph. Otherwise, please close the issue. I will refer users of my framework to this extra server if their needs include channel authorisation

I checked the laravel repo but they rolled out a more complicated method for everything (the cookie and jwt bindings, for instance), than the original. I think abstractions should be easier than what they build upon

An unrelated question: do you mind explaining the difference or importance of this 2?

The supported options are:
subscribe: the list of topic selectors to include in the mercure.subscribe claim of the JWT
publish: the list of topic selectors to include in the mercure.publish claim of the JWT

Are they relevant to me, as I'm not using twig? If yes, how do they fit into the programmatic invocation? My expected flow would've been on client connect, it opens the event source object with a list of topics it wants to subscribe to. It then sends a http request to a controller, where a decision is made whether or not this client is authorised to join (this way, data can be published safely to all members). Perhaps, the jwt/cookie from this endpoint would include list of authorised topics under the subscribe key? What about publish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants