rate-limit
rate-limit copied to clipboard
Fatal error: Uncaught Error: Class 'RateLimit\Rate' not found
Please guide me how to fix this error
Fatal error: Uncaught Error: Class 'RateLimit\Rate' not found
`<?php use RateLimit\Exception\LimitExceeded; use RateLimit\Rate; use RateLimit\RedisRateLimiter; use Redis; require_once("./vendor/autoload.php"); $rateLimiter = new RedisRateLimiter(Rate::perMinute(100), new Redis());
$apiKey = 'abc123';
try { $rateLimiter->limit($apiKey);
//on success
} catch (LimitExceeded $exception) { //on limit exceeded }`
Hi, which version are you using?
Also, put require_once("./vendor/autoload.php");
at the top of your script, before use
statements. Also, make sure that vendor/autoload.php
really exists on that path, i.e. make sure you run composer install
.
php version is 7.4 and "nikolaposa/rate-limit": "^1.0"
As you said, I changed the script, but the error is still displayed
Did you run composer install
? Did you check whether this file ./vendor/autoload.php
exists on that location on your machine?
Yes, there is an autoload.php file in the ./vendor path I ran the composer install command again and it was ok
composer install Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Nothing to install, update or remove Generating autoload files
But still there is the following error Fatal error: Uncaught Error: Class 'RateLimit\Rate' not found
Well that's very weird, seems like some basic miss-configuration in your setup. Class loading is a basic thing, no one else complained with this type of issues.