Stichoza / google-translate-php

🔤 Free Google Translate API PHP Package. Translates totally free of charge.
MIT License
1.79k stars 380 forks source link

Error: Class "Stichoza\GoogleTranslate\GoogleTranslate" not found in file #200

Closed ShazinAhmed97 closed 4 months ago

ShazinAhmed97 commented 8 months ago

when it runs on the local server there is no issue at all its working perfect .. but when i test it on liver server this error shows i tried many changes but no use

use Stichoza\GoogleTranslate\GoogleTranslate;

private function translateProducts($products, $targetLanguage) { $translator = new GoogleTranslate();

    // Set the target language
    $translator->setTarget($targetLanguage);

    if (is_array($products))
    {
        $translatedProducts = [];
        foreach ($products as $product) {
            $translatedProducts[] = $translator->translate($product);
        }
    }
    else
    {
        $translatedProducts = $translator->translate($products);
    }

    //print_r($translatedProducts); die();
    return $translatedProducts;
}`

this is my function

Stichoza commented 8 months ago

Do you have your composer configured correctly? Seems like an issue with autoloader

ShazinAhmed97 commented 8 months ago

yes i have "autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/", "Stichoza\\GoogleTranslate\\" : "vendor/stichoza/google-translate/src)" } },

Stichoza commented 7 months ago

I cannot reproduce this bug, can you list steps for it?

ShazinAhmed97 commented 7 months ago

is there any restrictions for live server ?

Stichoza commented 7 months ago

There are no restrictions. Make sure you're deployment is correct

miztizm commented 4 months ago

I encountered the same error after installation, but after a few minutes, it worked fine (I believe it's a vscode issue).