-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"null" driver not settable via env variable #34
Comments
Use double qoutes on the enviroment variable. |
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:
|
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 I suspect this issue will also affect the "null" Broadcast driver. |
@dwightwatson I've managed to set my driver to null using your method as well as the However my unit tests are DIRE slow after this: 25seconds -> 7mins Are slow unit tests something you're seeing too? It may well be because I'm using the TntSearch driver however I wanted to see if this is a scout issue or their implementation issue. Although using their native implementation not the scout wrapper has no impact on testing speed. |
@dwightwatson that's an OK suggestion but there's a problem when, for development, you have it set to "algolia" in your .env phpunit will fall back on that value if no value is set in phpunit.xml. Basically it means that if you have your local driver set to algolia there's no easy way to override that for tests. Will be a fine solution for CI though where you can just omit the driver env variable completely. |
I agree,it would be good to change this "null" option to "none" or "disable" or some equivalent that won't confuse .env to typecasting null from a string to a null value. |
We've found a way around this that disables the auto indexing by default during unit tests, when we get around to writing the searching unit tests we can re enable it for those particular tests. I think we can close this issue now? |
You've found a solution using the PHPUnit configuration file, but this is still an issue with Scout configuration in general. I don't think this issue should be closed, and I think another option name should be chosen (or, support literal |
Ahh totally sorry I thought I was responding to an issue on a different repo RE the scout implementation within that project sorry ignore my post above |
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. |
I've had the same problem in my projects too - 'null' is a silly name to use for anything that goes through .env since Laravel turns it into a
<env name="SCOUT_DRIVER" value="null"/>
'driver' => env('SCOUT_DRIVER') ?? 'null', I was considering doing a PR to fix this problem by renaming the 'null' driver to something else. Wondering if it's worth my time though as I don't want to spend a bunch of time on it for to be rejected. |
@edcs Your workaround is basically the same as the others suggest. Passing a 2nd argument into This workaround fails however in the case where your local It should be fine for CI though where you tend not to set the |
Any solution here? It seems crazy that this hasn't been resolved... |
@calebporzio You have to use double quotes on the |
Thanks I think I just removed the reference to it and it defaults to null. Still not happy with the proposed solutions, but Oh well - thanks for the tip! |
Try add this to your .env file just like what works in phpunit.xml file
This way we don't have to 'hack' the scout config file |
This is no longer an issue; works fine after this: |
documentation for the lazy: https://laravel.com/docs/5.6/configuration#environment-variable-types |
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 phpnull
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.
The text was updated successfully, but these errors were encountered: