PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 29, 2022

[FIXED] Error: Cannot redeclare __autoload()

 January 29, 2022     composer-php, getid3, multimedia, php, symfony     No comments   

Issue

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

Solution

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.



Answered By - Sven
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing