<p>For Craft 3:</p>

<p><code>Craft::$app-&gt;config-&gt;general-&gt;{var name}</code></p>

CC BY-SA 3.0
2018-04-29T22:34:33.830Z
2018-04-29T22:34:33.830Z
Henry
<pre><code>craft()-&gt;config-&gt;get('JsPath');
</code></pre>

CC BY-SA 3.0
2015-09-24T10:26:17.673Z
2015-09-24T14:00:31.033Z
2015-09-24T14:00:31.033Z
garyconstable
<p>It is considered best practice to use the public get methods, so while the Craft 3 answer is correct, you should try to get in the habit of calling the methods.</p>
<pre><code>Craft::$app-&gt;getConfig()-&gt;getGeneral()-&gt;varName
</code></pre>
<p>It looks more verbose, but generally best practice and follows the coding guidelines.</p>
<p><a href="https://craftcms.com/docs/3.x/extend/coding-guidelines.html#app-component-getters" rel="nofollow noreferrer">https://craftcms.com/docs/3.x/extend/coding-guidelines.html#app-component-getters</a></p>

CC BY-SA 4.0
2022-04-22T08:17:32.370Z
2022-04-24T07:35:16.080Z
2022-04-24T07:35:16.080Z
James White
<p>Within the config folder there is a general.php file with various vars which are site specific. </p>

<p>how do i get at these from within a plugin?</p>

<p>Thanks for your help.</p>

CC BY-SA 3.0
2015-09-24T10:26:06.857Z
its ok i found it - craft()->config->get('JsPath'); for example.
garyconstable
<config><settings>
How do i get variables from general.php
# How do i get variables from general.php

(Asked by: username_0 on 2015-09-24)

Within the config folder there is a general.php file with various vars which are site specific.

how do i get at these from within a plugin?

Thanks for your help.

**Tags:** config, settings
> **Comments:**
> **username_0**: its ok i found it - craft()->config->get('JsPath'); for example.  

---

## 3 answers

### Answer by username_1 on 2018-04-29. Score: 8

For Craft 3:

`Craft::$app->config->general->{var name}`


---

### Answer by username_0 on 2015-09-24. Score: 7

craft()->config->get('JsPath');


---

### Answer by username_2 on 2022-04-22. Score: 4

It is considered best practice to use the public get methods, so while the Craft 3 answer is correct, you should try to get in the habit of calling the methods.
Craft::$app->getConfig()->getGeneral()->varName

It looks more verbose, but generally best practice and follows the coding guidelines.
https://craftcms.com/docs/3.x/extend/coding-guidelines.html#app-component-getters


---

