Support the ongoing development of Laravel.io →
posted 1 week ago
Last updated by @slemke76 1 week ago.
0

Hello Sebastian, So from what I can see it seems you would want to use the Config class to overwrite what Laravel's config function. You can first try clearing and rebuilding the config cache using:

php artisan config:clear
php artisan config:cache

If that doesn't work then in the app service provider ensure you are binding the new custom configuration in the register function. Like this:

$this->app->singleton(ConfigRepository::class, function ($app) {
            return new CustomConfigRepository($app['config']->all());
        });
0

Hello,

thanks for your reply.

would want to use the Config class to overwrite what Laravel's config function

No, that´s not my goal. I would like to use the Illuminate\Config functions without Laravel (therefore artisan is also not available). (Therefore I wrote it´s perhaps a bit off-topic :-)

I do not understand why the code above does not use a singleton (it should) when using Container->[..]->make.

Thanks, Sebastian

0

Oh okay, I get you now. So from what I can gather the binding method you are using would always create a new instance. Also the same is done with the App. I would try this:

// Bind the container itself to the instance
$container->singleton('app', function () use ($container) {
    return $container;
});

// Correctly bind the `config` instance as a shared singleton
$container->singleton('config', function () {
    return new Illuminate\Config\Repository();
});

I also had a question. Is there a reason you are using the Repository for the `class_alias` instead of the Config ?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.