Class db does not exist eloquent

A facade root has not been set

and other terrible errors.

This post for those who like me using Eloquent outside Laravel.
With config like this:

Sometime need to log queries or just count it.
Almost all google results show code like this:

But outside Laravel you will get errors written above.

I spent some time to get it work.
And now i got solution 😀

To get work query logs outside Laravel use this 🙂