1

I am using Symfony and currently trying to use getId3: https://github.com/phansys/GetId3

I installed it via composer as mentioned in the link provided. The installation was successful.

In the file where I want to use it, I have the following:

<?php
    use GetId3_GetId3 as GetId3;

    ...

    $this->getId3 = new GetId3;


    $fileInfo = $this->getId3->analyze($media->getBinaryContent()->getRealPath());

The error I get is the following:

FatalErrorException: Error: Cannot redeclare __autoload() (previously declared in /Users/etienne/Developpement/Ima-Tech/Clients/osc/vendor/phansys/getid3/GetId3/GetId3.php:69) in /Users/etienne/Developpement/Ima-Tech/Clients/osc/vendor/phansys/getid3/GetId3/GetId3.php line 69

And the error stack:

in /Users/etienne/Developpement/Ima-Tech/Clients/osc/vendor/phansys/getid3/GetId3/GetId3.php line 69
at ErrorHandler->handleFatalError() in /Users/etienne/Developpement/Ima-Tech/Clients/osc/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php line 219
at ErrorHandler->handleFatal() in /Users/etienne/Developpement/Ima-Tech/Clients/osc/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php line 0
at GetId3_GetId3->__construct() in /Users/etienne/Developpement/Ima-Tech/Clients/osc/vendor/phansys/getid3/GetId3/Module/AudioVideo/Quicktime.php line 94
at GetId3_Module_AudioVideo_Quicktime->Analyze() in /Users/etienne/Developpement/Ima-Tech/Clients/osc/vendor/phansys/getid3/GetId3/GetId3.php line 471
at GetId3_GetId3->analyze() in /Users/etienne/Developpement/Ima-Tech/Clients/osc/src/Application/Sonata/MediaBundle/Provider/VideoProvider.php line 70
etiennenoel
  • 575
  • 2
  • 15

1 Answers1

2

You are using an old, outdated and buggy version, which can be seen by your usage of that library.

Use at least version 2.0.0 of this package, not the 1.x versions. (It means you have to use a development version because neither version 2.0 or 2.1 has been tagged). That will introduce a namespace version of this library that will work because it does not try to initialize it's own internal autoloading.

All 1.x versions are simply broken, because instantiating GetId3 objects more than once will try to add that __autoload() function each time - and the second time is one time too much.

Sven
  • 69,403
  • 10
  • 107
  • 109
  • 1
    No, that's bad because it is the 1.x version. I see that there is a version 2.0.0-beta1 tagged, so you could use `~2.0@beta` as a version requirement. This will automatically update to any later version 2.x if it becomes available whenever you run `composer update`. – Sven Oct 07 '14 at 20:43