Laravel binds pathis into the Container like so
$this->instance('path.lang', $this->langPath());
in bindPathsInContainer() in /vendor/laravel/framework/src/Illuminate/Foundation/Application.php I'd like to change this path from within my Service Provider to something else.
I know that the container instance is accessible through $this->app from within a Service Provider, and so thought I could do
$this->app->instance('path.lang', 'my/path');
This however returns "class instance does not exist." Can anyone explain what's going on here? Also, why does referencing ANY property of the container, as in
$this->app->someProperty
lead to this error? Is there a way to edit someProperty from within a service provider? NB: I know this can be done by extending \Illuminate\Foundation\Application, as explained here but I'd like to do this from without having to touch Laravel's default files.
I think the path has to be absolute:
php artisan tinker
app()->instance('path.lang', '/home/user/you/project/something/something/that/exists);
You can also try it like that in your AppServiceProvider:
$this->app->instance('path.lang', $this->app->resourcePath().DIRECTORY_SEPARATOR.'mylang');