Open mloureiro opened 7 years ago
I would also like to know. The error is triggered in ElasticquentSupport.php line 13:
public static function isLaravel5()
{
return version_compare(Application::VERSION, '5', '>');
}
I replaced the line with "return true;" but am now getting another error:
FatalErrorException in ElasticquentServiceProvider.php line 18: Call to undefined function Elasticquent\config_path()
@tobias42 that's not a problem of Elasticquent. Lumen doesn't come with a lot of things, the helpers are one of those.
You can try to add an helper file into your project, with something like this:
if (! function_exists('config_path')) {
/**
* Get the configuration path.
*
* @param string $path
*
* @return string
*/
function config_path($path = '')
{
return app()->basePath().'/config'.($path ? '/'.$path : $path);
}
}
@MLoureiro thanks, but no idea where to add that. I'm pretty new to Lumen/Laravel. Were you able to make any progress with Lumen/Elasticquent on your end?
Yes, I'm using it in our search service. It uses a different approach than what I am used to, but it seems to work. I still want to dive more into the querying part, at this moment I'm using the client and making the queries with a couple of classes that we already had from the previous version
@tobias42 Did you ever manage to solve this issue? I am facing the exact same one right now.
@RickNas I've added this file:
app/helpers.php
<?php
if (! function_exists('config_path')) {
/**
* Get the configuration path.
*
* @param string $path
*
* @return string
*/
function config_path($path = '')
{
return app()->basePath().'/config'.($path ? '/'.$path : $path);
}
}
if (! function_exists('bcrypt')) {
/**
* Hash the given value.
*
* @param string $value
* @param array $options
*
* @return string
*/
function bcrypt($value, $options = [])
{
return app('hash')->make($value, $options);
}
}
if (! function_exists('isProductionEnv')) {
/**
* Check if we are in a production environment.
*
* @return string
*/
function isProductionEnv()
{
return app()->environment('production');
}
}
if (! function_exists('is_json')) {
/**
* Check if a string is a valid JSON
*
* NOTE: if decoding fails because JSON_ERROR_DEPTH it will still be considered a valid JSON string
*
* @param mixed $string
*
* @return bool
*/
function is_json($string)
{
if (!is_string($string)) {
return false;
}
json_decode($string);
return in_array(json_last_error(), [
JSON_ERROR_NONE,
JSON_ERROR_DEPTH,
]);
}
}
(these methods were copied from the laravel framework it self)
and I've added "files": ["app/helpers.php"]
to the autoload
of composer.
The errors should be gone after this.
Thanks @MLoureiro I will give it a try.
Hi there
I'm trying the package in a lumen application, and it is failing because there's no
Illuminate\Foundation\Application
.Does it work with Lumen?
update:
After a few tweaks it does.
But to be able to use in my project I added to fork and change that return, are there any plans to support or not Lumen?