TrustedProxy icon indicating copy to clipboard operation
TrustedProxy copied to clipboard

Merge config file in the service registration

Open ElfSundae opened this issue 7 years ago • 7 comments

In this PR, I simply renamed the boot to register, and deleted boot as it is unused for now.

mergeConfigFrom should be called in the register method, it means once the package being registered, its config are ready to use. Then other services can access them safely without caring about the order of application services bootstrap.

This is also mentioned in the official documentation:

To merge the configurations, use the mergeConfigFrom method within your service provider's register method.

publishes is useful only in the console application, and in the console application all services will be booted, so it does not matter putting publishes whether in register or boot method. Some core services also put it in register to make code organized, such as MailServiceProvider::registerMarkdownRenderer.

ElfSundae avatar Oct 13 '17 14:10 ElfSundae

I'll test it out but sounds good, appreciate it!

fideloper avatar Oct 13 '17 14:10 fideloper

Doesn't merged yet? I think this should be merged.

kargnas avatar Dec 04 '17 16:12 kargnas

😅

ElfSundae avatar Dec 04 '17 16:12 ElfSundae

Have a new born at home, things will be slow to change :D

If you can help test this on various versions of Laravel, that'd be great. This package is still meant to be backwards compatible for all Laravel 5.* if possible.

fideloper avatar Dec 04 '17 17:12 fideloper

@fideloper 😀 Congrats 🎉

ElfSundae avatar Dec 04 '17 17:12 ElfSundae

Thanks! On Mon, Dec 4, 2017 at 11:15 Elf Sundae [email protected] wrote:

@fideloper https://github.com/fideloper 😀 Congrats 🎉

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/fideloper/TrustedProxy/pull/90#issuecomment-349032929, or mute the thread https://github.com/notifications/unsubscribe-auth/AAch0zErHKvwJG9m6nV5-8IqKzT1rcPAks5s9CiogaJpZM4P4iNE .

fideloper avatar Dec 04 '17 18:12 fideloper

:-1: I'd dispute the recommendations in the docs actually. Makes much more sense to apply the config fallbacks during boot, since register shouldn't assume the config system is ready yet.

eg https://github.com/GrahamCampbell/Laravel-GitHub/blob/master/src/GitHubServiceProvider.php

GrahamCampbell avatar Dec 04 '17 18:12 GrahamCampbell