title: Yii2: Config params vs. const/define
body: <p>When should I use what?</p>
  
  <p>I have the option to define constants in the index.php entry script file like it is recommended in <a href="http://www.yiiframework.com/doc-2.0/guide-structure-entry-scripts.html#defining-constants" rel="nofollow noreferrer">Yii2 guide: constants</a>. Or I could use the params in the configuration - explained in <a href="http://www.yiiframework.com/doc-2.0/guide-structure-applications.html#params" rel="nofollow noreferrer">YII2 guide: params</a>. Both are per application and not really global.</p>
  
  <p>Currently, it seems to me that params are a bit less comfortable if I want to combine values like this:</p>
  
  <pre><code>define('SOME_URL',            'http://some.url');
  define('SOME_SPECIALIZED_URL', SOME_URL . '/specialized');
  </code></pre>
  
  <p>Besides, accessing is bit more code (<code>Yii::$app-&gt;params['something']</code>) compared to constants.</p>
  
  <p>So when should or could I use what?</p>
  
  <p><em>Small update</em>: in PHP 7 <code>define()</code> supports arrays as well, so the whole params structure can be configured as a constant. Probably better supported by IDEs.</p>