Answers.Body: <p>The issue is that you're putting the multi-environment config code in your <code>plugins/pluginHandle/config.php</code> file, which is just meant to supply default plugin config values.</p>
  
  <p>Users can set custom values in <code>craft/config/pluginHandle.php</code> which is where the multi-environment logic would also go.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-09T01:26:33.517Z
Answers.LastActivityDate: 2015-12-09T01:26:33.517Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have set up the plugin's multi-environment configuration as outlined in <a href="https://craftcms.stackexchange.com/a/2000/3584">this answer</a>.</p>
  
  <p>The <code>config.php</code> file for the plugin is as follows:</p>
  
  <pre><code>&lt;?php
  
  return array(
      // All
      '*' =&gt; array(
      ),
  
      // Development
      '.domain.dev' =&gt; array(
          'apiKey' =&gt; 'APIKEYDEVVALUE'
      ),
  
      // Staging
      'dev.domain.com' =&gt; array(
          'apiKey' =&gt; 'APIKEYSTAGINGVALUE'
      ),
  
      // Production
      'dev.domain.com' =&gt; array(
          'apiKey' =&gt; 'APIKEYPRODVALUE'
      ),
  );
  </code></pre>
  
  <p>But calling <code>craft()-&gt;config-&gt;get('apiKey', 'pluginhandle')</code> returns <code>null</code>.</p>
  
  <p>If I <code>var_dump(craft()-&gt;config)</code> I can see that the config file for the plugin is loaded by craft.</p>
  
  <p>What am I missing?  Please let me know if I can provide any more useful info.</p>
  
Tags: <plugin-development><config><multi-environment>
Title: Plugin Multi-Environment config not working
ThreadText: # Plugin Multi-Environment config not working
  
  (Asked by: username_0 on 2015-12-08)
  
  I have set up the plugin's multi-environment configuration as outlined in [this answer](https://craftcms.stackexchange.com/a/2000/3584).
  
  The `config.php` file for the plugin is as follows:
  
  ```
  <?php
  
  return array(
      // All
      '*' => array(
      ),
  
      // Development
      '.domain.dev' => array(
          'apiKey' => 'APIKEYDEVVALUE'
      ),
  
      // Staging
      'dev.domain.com' => array(
          'apiKey' => 'APIKEYSTAGINGVALUE'
      ),
  
      // Production
      'dev.domain.com' => array(
          'apiKey' => 'APIKEYPRODVALUE'
      ),
  );
  
  ```
  
  But calling `craft()->config->get('apiKey', 'pluginhandle')` returns `null`.
  
  If I `var_dump(craft()->config)` I can see that the config file for the plugin is loaded by craft.
  
  What am I missing? Please let me know if I can provide any more useful info.
  
  **Tags:** plugin-development, config, multi-environment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-12-09. Score: 4 | Accepted answer
  
  The issue is that you're putting the multi-environment config code in your `plugins/pluginHandle/config.php` file, which is just meant to supply default plugin config values.
  
  Users can set custom values in `craft/config/pluginHandle.php` which is where the multi-environment logic would also go.
  
  
  ---
  
  