After multiple tests, I'm finding that I can't access a module's config file with an "external" PHP file that has "backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL);"  This "external" PHP file is in the same directory as "my_mod.module" and is being called through ajax in a function in the "my_mod.module" file.

Yes, BACKDROP_BOOTSTRAP_FULL is running correctly (I can access users, nodes, etc. in the external file). However, when trying to call a config file for same module in the external file, "$config = config('my_module.settings');"  it returns an Object but the "data" element is  empty.

Just wondering if,

A.) This is known and this is how it should work?

B.) This is not known and maybe should be looked into?

C.) if there is a work-around or fix?  I can pass the VARs through the ajax call... but using that method is just a bit messy.

===========
var_dump of config in module's function
----------
object(Config)[71]
  protected 'name' => string 'my_module.settings' (length=32)
  protected 'isNew' => boolean false
  protected 'data' =>
    array (size=11)
      'var_01' => string 'my_data_01' (length=9)
      'var_02' => string 'my_data_02' (length=9)
      'var_03' => string 'my_data_03' (length=9)
  protected 'overrides' => null
  protected 'validated' => boolean false
  protected 'storage' =>
    object(ConfigFileStorage)[68]
      protected 'directory' => string './files/config_026255f7c13da4d5d63cedc0538134df/active' (length=54)
  protected 'context' => null
  protected 'isLoaded' => boolean true
 

===========
var_dump of config in external PHP file with BACKDROP_BOOTSTRAP_FULL
----------
object(Config)[57]
  protected 'name' => string 'my_module.settings' (length=32)
  protected 'isNew' => boolean true
  protected 'data' =>
    array (size=0)
      empty
  protected 'overrides' => null
  protected 'validated' => boolean false
  protected 'storage' =>
    object(ConfigFileStorage)[61]
      protected 'directory' => string './files/config_026255f7c13da4d5d63cedc0538134df/active' (length=54)
  protected 'context' => null
  protected 'isLoaded' => boolean true

Comments

JugglingCoder, the function config() will always look for the file in the files/config_XXX/active directory, not in the module's config folder. That's why it's empty - the config probably doesn't exist in files/config_XXX/active

When you install and enable a module, Backdrop will move the modules config files located in the module's config folder  to files/config_XXX/active. I'm not sure why this is not happening for you. 

Thank you for your reply argiepiano.  Yes, I know about the config file being moved to the "files/config_XXX/active" directory.

One would assume if "BACKDROP_BOOTSTRAP_FULL" is loaded, the "config()" function would work just as it does in a backdrop file but...

I tried multiple path combinations to load the config file but all failed:

// Multiple tries
// =====
// Standard method, works fine throughout backdrop site
// $config = config('a.settings');  // FAILS
// =====
// Using "config_get_config_directory" > https://docs.backdropcms.org/api/backdrop/core%21includes%21config.inc/f...
// $config_directory = config_get_config_directory($type = 'active');
// $config = config($config_directory . '/a.settings'); // FAILS
// =====
// Direct Path
// $config = config('files/config_026255f7c13da4d5d63cedc0538134df/active/a.settings'); // FAILS
// $config = config('/files/config_026255f7c13da4d5d63cedc0538134df/active/a.settings'); // FAILS

Graphic of file layout:

File layout