Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

paboo's avatar
Level 1

Class 'Symfony\Component\EventDispatcher\Event' not found

i was get bug from Event when i upload my image in server


Error
Class 'Symfony\Component\EventDispatcher\Event' not found in line 10

and this my code call Event

 public static function uploadFileStore($file, $nameDir, $redirect = 'Admin\Admin', $params = [])
    {
        $storage = \App\Common\Factory\Storage::getInstance()->getDriver();
        $rand = rand(1, 100000);
        $milliseconds = self::milliseconds();
        $file_name = $nameDir . '/' . $milliseconds . '-' . $rand . '-' . Utility::makeFilename($file->getClientOriginalName());
        try {
            $storage->put($file_name, $file->path());
            return $attachFile = $file_name;
        } catch (S3Exception $e) {
            return redirect()->action($redirect, $params)
                ->withError(__('messages.upload.validate.upload_error'));
        }
    }

code die after calling put method. and this is put method

public function put($key, $filePath)
    {
        $log = new Log('aws');
        try {
            $client = S3Client::factory($this->getConfigs());
            $response = $client->putObject(array(
                'Bucket' => $this->getBucket(),
                'Key' => $key,
                'SourceFile' => $filePath,
                'ContentType' => mimetype_from_filename($key),
            ));


            $log->addRecord("Success: put file", Log::INFO, ['data' => $response]);

            return $response;
        } catch (S3Exception $e) {
            $log->addRecord("Error: put file", Log::ERROR, ['data' => $e]);
        }
    }

and i try using another class

use Illuminate\Http\Testing\MimeType;

and i change method calling $key

'ContentType' => MimeType::from($key),


this code in line 10 in file vendor/guzzle/guzzle/src/Guzzle/Common/Event.php

0 likes
7 replies
bobbybouwmann's avatar

Did you run composer install? It sounds to me that you're missing some dependencies.

5 likes
Snapey's avatar

why not use flysystem AWS driver? its well tested and proven

1 like
paboo's avatar
Level 1

@bobbybouwmann i was remove vendor and composer.lock many time but it's told me that error. when i try debug that error i found method putObject() it's not working

1 like
paboo's avatar
Level 1

@snapey i upgrade version up to 8.4. but it still error i will using your recommended :D

madsynn's avatar

Anyone working on this I have the same issue?

paboo's avatar
Level 1

or run command composer update --no-cache

1 like
paboo's avatar
Level 1

try upgrade your package follow this website

https://packagist.org/packages/laravel/laravel 

Please or to participate in this conversation.