Jesse Schutt
← All writing

Parsing ENV Boolean Values in Laravel

How do we ensure boolean values are parsed as such when using a .env file in Laravel?

I've been curious how Laravel parses strings of true and false from a .env file so I did a bit of digging. Fortunately I didn't have to look too far because the documentation gives a clear picture of what is going on behind the scenes.

In short, the `env()` helper calls a function that will look for any of the following values:

  • true
  • (true)
  • false
  • (false)
  • null
  • (null)
  • empty
  • (empty)

If it encounters any of these values it converts them to their native php types for us!

More on software