Skip to content
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

Call to undefined method Illuminate\Support\Facades\Redis::connect() #115

Open
chis0m opened this issue Apr 2, 2023 · 5 comments
Open

Comments

@chis0m
Copy link

chis0m commented Apr 2, 2023

So installed the package in a Laravel 8.x application and I tried testing by running this part of the example

$adapter = new Redis(config('prometheus.redis'));
$registry = new CollectorRegistry($adapter, false);
$renderer = new RenderTextFormat();
$result = $renderer->render($registry->getMetricFamilySamples());
return response()->json(['data' => $result]);

And I am getting the error
Call to undefined method Illuminate\Support\Facades\Redis::connect()
Which occurs in the package
vendor/promphp/prometheus_client_php/src/Prometheus/Storage/Redis.php:225

How do I fix this?
Thanks

@Alitindrawan24
Copy link

Same issue here, Is this because I'm using a certain Laravel version or is there another problem?

@Alitindrawan24
Copy link

@chis0m I am already solved this issue by installing PHP Redis extension, you can following this to phpredis installation https://github.com/phpredis/phpredis/blob/develop/INSTALL.md

@Goopil
Copy link

Goopil commented Dec 11, 2023

if you're using this package in laravel. Prefer to reuse the defined connection.

$connection = $this->app->make('redis')->connection(config('prometheus.redis'))->client();
$adapter = Redis::fromExistingConnection($connection);
$registry = new CollectorRegistry($adapter, false);
$renderer = new RenderTextFormat();
$result = $renderer->render($registry->getMetricFamilySamples());
return response()->json(['data' => $result]);

@OmdaMukhtar
Copy link

I solve this issue by installing php7.4-redis depending on your PHP version.

sudo apt install php7.4-redis
# verify php -m | grep redis
sudo systemctl restart apache2

after that no more Call to undefined method Illuminate\Support\Facades\Redis::connect()

@chis0m
Copy link
Author

chis0m commented Aug 29, 2024

Thank you guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants