Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoloader expected class #2747

Closed
EtienneDx opened this issue Sep 17, 2018 · 4 comments
Closed

Autoloader expected class #2747

EtienneDx opened this issue Sep 17, 2018 · 4 comments

Comments

@EtienneDx
Copy link

Hey, I've been struggling for a few days and no one seems to have the answer on stackoverflow either, so here I am. I've been using symfony 4 successfully till about 5 days ago, when a sudden bug appeared on the online version. I decide to re upload everything but a bug remain, the autoloader doesn't manage to load any class from twig. Looking at the code for the classes, they are all inside some if(\false) conditions, which obviously explains why the classes aren't loading. Is this intended and if so how can I fix my project, or is it an error that happened due to the replacement of require_once by class_exists (the commit was on the 17 of june 2017 so I don't get how comes it stopped working just now). Here's one of the file that causes problem :
<?php namespace Twig\Extension; class_exists('Twig_ExtensionInterface'); if (\false) { interface ExtensionInterface extends \Twig_ExtensionInterface { } }
this is from https://github.com/twigphp/Twig/blob/2.x/src/Extension/ExtensionInterface.php

Here's my bug report from symfony :
image
.........
image

I really need to get this project working soon, so any help would be apreciated :)

@linaori
Copy link

linaori commented Sep 17, 2018

Have you verified that the file listed in the error message exists?

@EtienneDx
Copy link
Author

EtienneDx commented Sep 17, 2018 via email

@Tobion
Copy link
Contributor

Tobion commented Nov 1, 2018

The namespaced classes like https://github.com/twigphp/Twig/blob/2.x/src/Environment.php are only there for your IDE and not actually used (which is why they are wrapped in false).
Instead, the namespaced classes are just aliases, see

class_alias('Twig_Environment', 'Twig\Environment', false);

There should not be any problem normally. I can imagine, that you still have old versions of the classes in opcache and thus the aliases are not loaded. So try clearing opcache.
Are you using the composer autoloader?

@fabpot
Copy link
Contributor

fabpot commented Dec 16, 2018

Closing as there is no more feedback from the reporter.

@fabpot fabpot closed this as completed Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants