You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-28Lines changed: 20 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,48 +127,40 @@ The hub will be available at `http://localhost:3000/.well-known/mercure`.
127
127
128
128
## Configuration
129
129
130
-
The plugin includes a default configuration file with all available options. The configuration is automatically loaded from the plugin's `config/mercure.php` file.
130
+
The plugin comes with sensible defaults and multiple configuration options.
131
131
132
-
Set the required environment variables in your `.env` file:
132
+
**Quick Setup (Environment Variables):**
133
+
134
+
For development, the fastest way to get started is using environment variables in your `.env` file:
2.**Your overrides** - `config/app_mercure.php` (optional, loaded after plugin defaults)
148
+
149
+
Create `config/app_mercure.php` in your project to customize any settings. Your values will override the plugin defaults.
150
+
151
+
**Cross-Subdomain Setup:**
152
+
140
153
> [!NOTE]
141
-
> If your Mercure hub is running on a different subdomain than your CakePHP application, you need to set the cookie domain to the top-level domain:
154
+
> If your Mercure hub runs on a different subdomain than your CakePHP application (e.g., `hub.example.com` vs `app.example.com`), you must configure the cookie domain:
142
155
>
143
156
> ```env
144
-
> # For cross-subdomain authorization
157
+
> # Allow cookie sharing across subdomains
145
158
> MERCURE_COOKIE_DOMAIN=.example.com
146
159
> ```
147
160
>
148
-
> This allows the authorization cookie to be accessible by both your application and the Mercure hub when they are on different subdomains of the same parent domain.
'public_url' => null, // Optional, defaults to 'url'
156
-
'jwt' => [
157
-
'secret' => '!ChangeThisMercureHubJWTSecretKey!',
158
-
'algorithm' => 'HS256',
159
-
'publish' => ['*'],
160
-
'subscribe' => ['*'],
161
-
],
162
-
]
163
-
```
161
+
> This enables the authorization cookie to be accessible by both your application and the Mercure hub. Without this setting, authorization will fail for cross-subdomain requests.
164
162
165
-
The `url` is used by your CakePHP application to publish updates. Set `public_url` when clients need to connect to a different URL (e.g., when using Docker with internal networking).
166
-
167
-
To customize the configuration, copy the plugin's config file to your application:
For a complete list of available environment variables, see the plugin's `config/mercure.php` [file](https://github.com/josbeir/cakephp-mercure/blob/main/config/mercure.php).
172
164
173
165
## Basic Usage
174
166
@@ -397,7 +389,7 @@ Publisher::publish($update);
397
389
> **View Class Configuration:** By default, `ViewUpdate` uses CakePHP's automatic view class selection (your `AppView` if it exists, otherwise the base `View` class). You can override this by setting `view_class` in your configuration:
0 commit comments