<p>Add this at the top of <code>config/general.php</code> file:</p>

<pre><code>use craft\elements\Entry;
</code></pre>

<p>And change your <code>loginPath</code> value to:</p>

<pre><code>'loginPath' =&gt; function() {
   return Entry::find()-&gt;section('login')-&gt;one()-&gt;url ?? null;
},
</code></pre>

CC BY-SA 4.0
2020-02-28T10:50:09.947Z
Thanks! I tried something similar - i pasted "use Craft", but it didnt helped. I wonder why.
Piotr Pogorzelski
CC BY-SA 4.0
2020-02-28T10:52:40.560Z
Please confirm and/or upvote for this answer it you think this is a right and viable solution :)
Romain P.
CC BY-SA 4.0
2020-02-28T10:40:09.660Z
2020-02-28T10:40:09.660Z
Romain P.
<p>Can i use element queries in <code>general.php</code> file? I wanted to set <code>loginPath</code> based on entry query, like this:</p>

<pre><code>'loginPath' =&gt; Craft::$app-&gt;entries-&gt;section('login')-&gt;one()-&gt;url ?? false,
</code></pre>

<p>Hovewer, i get error:</p>

<pre><code>( ! ) Fatal error: Uncaught Error: Class 'Craft' not found in C:\xampp\htdocs\xxx\config\general.php on line 40
</code></pre>

<config>
Using element queries in general.php config file
# Using element queries in general.php config file

(Asked by: username_0 on 2020-02-28)

Can i use element queries in general.php file? I wanted to set loginPath based on entry query, like this:
'loginPath' => Craft::$app->entries->section('login')->one()->url ?? false,

Hovewer, i get error:
( ! ) Fatal error: Uncaught Error: Class 'Craft' not found in C:\xampp\htdocs\xxx\config\general.php on line 40

**Tags:** config

---

## 1 answers

### Answer by username_1 on 2020-02-28. Score: 3 | Accepted answer

Add this at the top of config/general.php file:
use craft\elements\Entry;

And change your loginPath value to:
'loginPath' => function() {
   return Entry::find()->section('login')->one()->url ?? null;
},

> **Comments:**
> **username_0**: Thanks! I tried something similar - i pasted "use Craft", but it didnt helped. I wonder why.  
> **username_1**: Please confirm and/or upvote for this answer it you think this is a right and viable solution :)  

---

