scout: "null" driver not settable via env variable
When trying to set the scout engine to the “null” implementation (e.g. say as a fallback for when no env variable exists: 'driver' => env('SCOUT_DRIVER', 'null')
or for tests) the string "null"
is parsed into a php null
value instead resulting in an instantiation error.
Suggest either renaming the null driver so something else like nullsearcher unless there is a way in phpunit.xml and .env it can be set as a string.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 18 (8 by maintainers)
Commits related to this issue
- Use double quotes for null driver, see https://github.com/laravel/scout/issues/34\#issuecomment-241569168 — committed to jonnybarnes/jonnybarnes.uk by jonnybarnes 8 years ago
Try add this to your .env file just like what works in phpunit.xml file
SCOUT_DRIVER='"null"'
This way we don’t have to ‘hack’ the scout config file
@calebporzio You have to use double quotes on the
SCOUT_DRIVER
null value. Like this:<env name="SCOUT_DRIVER" value='"null"'/>
This is no longer an issue; works fine after this:
https://github.com/laravel/scout/pull/224
Hello, I found a solution. You need to setup it in reversed way. Instead in your .env file put
and in config/Scout.php
Put in .env
and in config/Scout.php
Of course then you can just remove it from local environment and it will means that it will use null.
Using double quotes on the environment variable doesn’t work. I’ve been trying to do this to disable Laravel Scout in my test environment. Dotenv must take the string “null” to become null as well.
My solution in the meantime has been to set the default driver to “null” in the
config/scout.php
file and then set it to “algolia” through an environment variable in production, but clearly this isn’t great.I suspect this issue will also affect the “null” Broadcast driver.
How would one do that in a phpunit.xml file where the values are already between quotes?
Presumably I could use single quotes to wrap it but I haven’t yet tested if it works: