Comments (18)
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
from scout.
@calebporzio You have to use double quotes on the SCOUT_DRIVER
null value. Like this:
<env name="SCOUT_DRIVER" value='"null"'/>
from scout.
Hello, I found a solution. You need to setup it in reversed way. Instead in your .env file put
SCOUT_DRIVER=null
and in config/Scout.php
'driver' => env('SCOUT_DRIVER', 'algolia')
Put in .env
SCOUT_DRIVER=algolia
and in config/Scout.php
'driver' => env('SCOUT_DRIVER', 'null')
Of course then you can just remove it from local environment and it will means that it will use null.
from scout.
This is no longer an issue; works fine after this:
from scout.
How would one do that in a phpunit.xml file where the values are already between quotes?
<env name="SCOUT_DRIVER" value="null" />
Presumably I could use single quotes to wrap it but I haven't yet tested if it works:
<env name="SCOUT_DRIVER" value='"null"' />
from scout.
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.
SCOUT_DRIVER="null"
>>> env('SCOUT_DRIVER');
=> null
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.
from scout.
Use double qoutes on the enviroment variable.
from scout.
@dwightwatson I've managed to set my driver to null using your method as well as the <env name="SCOUT_DRIVER" value='"null"' />
method too.
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.
from scout.
@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.
from scout.
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.
from scout.
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?
from scout.
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 null
as being the "null" driver).
from scout.
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
from scout.
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 null
. My workaround to get it to work nicely with PHPUnit is this (will only work on PHP 7.0 and above though):
phpunit.xml
<env name="SCOUT_DRIVER" value="null"/>
config/scout.php
'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.
from scout.
@edcs Your workaround is basically the same as the others suggest. Passing a 2nd argument into env()
has the same effect.
This workaround fails however in the case where your local .env
file has the driver set to something else (e.g. alogolia
). Then, simply omitting SCOUT_DRIVER
from phpunit.xml will not mean your tests will use the 'null' driver as laravel will fall back on the .env
file and try to use algolia. This means that when you run your tests locally you'll be using the driver you set for development work.
It should be fine for CI though where you tend not to set the SCOUT_DRIVER
at all.
from scout.
Any solution here? It seems crazy that this hasn't been resolved...
from scout.
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!
from scout.
documentation for the lazy:
https://laravel.com/docs/5.6/configuration#environment-variable-types
from scout.
Related Issues (20)
- Feature request: Provide contract to go with Searchable trait methods HOT 1
- MakeSearchable job runs even if model was not changed HOT 1
- Relationship with ManyToMany HOT 1
- Scout currently supports where clause that uses equal (=) operator only. Additional comparison (i.e >, >=, < ...) operation support is required. HOT 2
- php artisan scout:import error HOT 3
- Scout always returning an empty response but paginateRaw returns data HOT 5
- Support queryCallback in CollectionEngine HOT 1
- Formatting data based on the search field HOT 1
- Scout import command didn't indexed all the records in meilisearch HOT 1
- Meilisearch facetDistribution / raw attributes HOT 3
- Search downtime when running `scout:import` with Algolia HOT 2
- Method Laravel\Scout\Builder::withSearchParameters does not exist. HOT 7
- Typesense: Search throws exception -> fields is required HOT 5
- Typesense: Import exception not properly thrown HOT 1
- We need more operators in where clauses HOT 2
- Warn when using null driver HOT 1
- use scopeSearch to allow searching on relationships HOT 1
- Artisan scout commands not defined. HOT 1
- Add a fake() for scout HOT 4
- Exception when searching large datasets for common query using paginate HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scout.