Using element queries in general.php config file Can i use element queries in general.php file? I wanted to set loginPath based on entry query, like this:

'loginPath' =&gt; Craft::$app-&gt;entries-&gt;section('login')-&gt;one()-&gt;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
Add this at the top of config/general.php file:

use craft\elements\Entry;


And change your loginPath value to:

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