rate-limit icon indicating copy to clipboard operation
rate-limit copied to clipboard

Fatal error: Uncaught Error: Class 'RateLimit\Rate' not found

Open cafefars opened this issue 2 years ago • 5 comments

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 }`

cafefars avatar Sep 14 '22 03:09 cafefars

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.

nikolaposa avatar Sep 14 '22 09:09 nikolaposa

php version is 7.4 and "nikolaposa/rate-limit": "^1.0"

As you said, I changed the script, but the error is still displayed

cafefars avatar Sep 14 '22 13:09 cafefars

Did you run composer install? Did you check whether this file ./vendor/autoload.php exists on that location on your machine?

nikolaposa avatar Sep 14 '22 16:09 nikolaposa

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

cafefars avatar Sep 14 '22 16:09 cafefars

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.

nikolaposa avatar Sep 16 '22 09:09 nikolaposa