api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.45k stars 878 forks source link

Mercure hub_url config docs need updating for use with bundle ^0.3 #4451

Closed silverbackdan closed 3 years ago

silverbackdan commented 3 years ago

API Platform version(s) affected: 2.6.5

Description
See here too: https://github.com/api-platform/api-platform/issues/2005 Setting the hub_url in the configuration with an environment variable results in an error saying the environment variable is not being used.

How to reproduce
Use the configuration

api_platform:
    mercure:
        hub_url: '%env(MERCURE_SUBSCRIBE_URL)%'

Possible Solution
Unsure yet where the issue lies.

Additional Context
This issue does not occur in <=2.6.4

silverbackdan commented 3 years ago

So I can see the environment variable is not being used because I'm using the mercure package which includes the Discovery class: https://github.com/api-platform/core/blob/main/src/Core/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L688

So the hub URL is only configured with this variable if the Symfony\Component\Mercure\Discovery class does not exist... so I imagine docs are out of date and I'm just trying to see how to configure the hub URL now

silverbackdan commented 3 years ago

Got it, I reinstalled the recipe for the mercure bundle and see the new environment variables which the bundle uses now:

###> symfony/mercure-bundle ###
# See https://symfony.com/doc/current/mercure.html#configuration
# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
MERCURE_URL=https://127.0.0.1:8000/.well-known/mercure
# The public URL of the Mercure hub, used by the browser to connect
MERCURE_PUBLIC_URL=https://127.0.0.1:8000/.well-known/mercure
# The secret used to sign the JWTs
MERCURE_JWT_SECRET="!ChangeMe!"
###< symfony/mercure-bundle ###

Anyone updating to api platform 2.6.5 with mercure bundle ^0.3 should update their environment variables and configuration.