Skip to content

Commit b518aa3

Browse files
committed
Add configuration file override
1 parent ea5cb9b commit b518aa3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ The hub will be available at `http://localhost:3000/.well-known/mercure`.
129129

130130
The plugin includes a default configuration file with all available options. The configuration is automatically loaded from the plugin's `config/mercure.php` file.
131131

132-
Set the required environment variables in your `.env` file:
132+
You can also create a `config/app_mercure.php` file in your project which will be loaded after the plugin config file, allowing you to override any settings.
133+
134+
Alternatively you can set a few environment variables in your `.env` file for quick setup. Refer to the `mercure.php` for a full list of predefined env variables:
133135

134136
```env
135137
MERCURE_URL=http://localhost:3000/.well-known/mercure
@@ -397,7 +399,7 @@ Publisher::publish($update);
397399
> **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:
398400
>
399401
> ```php
400-
> // In config/mercure.php
402+
> // In config/app_mercure.php
401403
> return [
402404
> 'Mercure' => [
403405
> 'view_class' => \App\View\CustomView::class,

src/MercurePlugin.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public function bootstrap(PluginApplicationInterface $app): void
2626

2727
// Load plugin configuration
2828
Configure::load('Mercure.mercure');
29+
30+
// Load app specific config file.
31+
if (file_exists(ROOT . DS . 'config' . DS . 'app_mercure.php')) {
32+
Configure::load('app_mercure');
33+
}
2934
}
3035

3136
/**

0 commit comments

Comments
 (0)