saqueib
168
1
Testing

Custom package config value not accessible in laravel app

Posted 1 year ago by saqueib

I am having some issue my package which I am developing using orchestral/testbench.

Its laravel 5.5 package, I am not able to access the package's config value but same is working when I run packages phpunit test.

here is how I am accessing it in my package controllers

config('mypackage::allowed_access')

It passes the test but when I use this package in a laravel app above for testing as a path repository above is returning null.

Now if I change this to config('mypackage.allowed_access') I am able to access it in my laravel app but now my tests are failing since its not accecible in package now :(

MyPackageServiceProvider

public function boot()
{
    // Publish config 
    $this->publishes([
        __DIR__.'/Config/mypackage.php' => config_path('mypackage.php'),
    ], 'mypackage_config');
    ....
}

public function register()
{
    $this->mergeConfigFrom(
        __DIR__.'/Config/mypackage.php', 'mypackage'
    );
}

Please help whats I am doing wrong

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.