0

I'm currently having a mental breakdown, hitting my head against different walls. I'm trying to get my app online to prod, and have been trying for weeks now. I've had this error a lot : Symfony - twig - Autoloader expected class

Now, it's evolved, and I have this : enter image description here

Sometime, after clearing cache, running composer install / update a dozen time, this error goes away and..... I get the old error again!

Please help if you've ever seen anything like this

1 Answers1

0

How are you making deployment on prod environment? Maybe there are some files doubled so loader doesn't recognize them correctly? Some deployment methods dont remove files deleted at project (php storm deploy).

Last times i had error with Twig_Environment. It was after i upgraded my project's Symfony version from 3.3 to 3.4.

To Sf 3.3 all services defined at services.yml at enabled bundles was PUBLIC. Since 3.4 they are all PRIVATE by default. What i did was to add some .yml code at every services.yml file i had:

_defaults:
    public: true

Without this code Twig_Environment could not see some Twig Extensions and other classes.

Also I have read your last post. So You don't have access to console, yup?

Maybe try to have second instance of Your project (locally) where everything is set up to prod env? Then try to:

composer dump-autoload -o

And other preparings for prod:

php bin/console a:install --symlink
php bin/console a:dump --env=prod
php bin/console c:c --env=prod

After this You should upload vendor/autoload.php, generated assets, etc. at production server. And this should happen every site update. It's really bad having Sf project withoud ssh access.

Igor W.
  • 381
  • 3
  • 11