Page 1 of 1

Opencart Version 3.0.2.0:- Cannot redeclare class Composer in system/library/template/Twig/Autoloader.php

Posted: Mon Oct 15, 2018 8:55 pm
by balwant
Opencart Version 3.0.2.0:-

i was working on Opencart Version 3.0.2.0 site, after doing some modifation in header.twig file (i have added this code in header.twig file, locaiton => http://prntscr.com/l5n71s )

but after adding this code I am getting this error = >http://prntscr.com/l5n7if.

I reverted back my changes, even i restore this file with an old backup file that i downloaded just before to start changes and after that clear and refresh cache from admin section => https://prnt.sc/l5n7x8, but still, I am getting the same error, I don't know how to fix this error. please help me to fix this issue

Thanks :

Re: Opencart Version 3.0.2.0:- Cannot redeclare class Composer in system/library/template/Twig/Autoloader.php

Posted: Tue Oct 16, 2018 5:49 pm
by paulfeakins
balwant wrote:
Mon Oct 15, 2018 8:55 pm
even i restore this file with an old backup file
But this is stored in the database isn't it?

Re: Opencart Version 3.0.2.0:- Cannot redeclare class Composer in system/library/template/Twig/Autoloader.php

Posted: Tue Oct 16, 2018 6:06 pm
by balwant
NO, this is not stored in the database, the issue is fixed now. it just because of adding \Composer::register(); code instead of \Twig_Autoloader::register(); in twig.php file

Thanks

Re: Opencart Version 3.0.2.0:- Cannot redeclare class Composer in system/library/template/Twig/Autoloader.php

Posted: Mon Sep 14, 2020 1:42 pm
by AmPumped
Hi

Am facing the same. What we have to do to fix the issue? I do see \Composer::register(); in ma twig.php file :(

Re: Opencart Version 3.0.2.0:- Cannot redeclare class Composer in system/library/template/Twig/Autoloader.php

Posted: Thu Oct 15, 2020 5:59 am
by helsik
нужно в редакторе шаблона (в админ панели опенкарта) удалить редактируемый файл после которого появилась ошибка, почистить кеш и после этого ошибка пропадет сама.

Re: Opencart Version 3.0.2.0:- Cannot redeclare class Composer in system/library/template/Twig/Autoloader.php

Posted: Thu Oct 15, 2020 6:17 pm
by paulfeakins
balwant wrote:
Tue Oct 16, 2018 6:06 pm
NO, this is not stored in the database, the issue is fixed now. it just because of adding \Composer::register(); code instead of \Twig_Autoloader::register(); in twig.php file
If this is now fixed please add [SOLVED] to the beginning of the post title.

Re: Opencart Version 3.0.2.0:- Cannot redeclare class Composer in system/library/template/Twig/Autoloader.php

Posted: Thu Oct 15, 2020 7:56 pm
by JNeuhoff
The system/library/template/twig.php uses this:

Code: Select all

$loader = new \Twig_Loader_Filesystem(DIR_TEMPLATE);
The OP isn't telling us the whole story here, because he must have done some other changes, too, breaking his OpenCart 3.0.2.0.