PHP Fatal error: Class ‘Twig_Loader_Filesystem’ not found


Oops, the private WordPress blog I administer during my off hours on an Azure WebApp went dark with 500 Internal Server Error on all web requests.

<Temporary failure to upload media to the blog, pending screenshot>

The App Service built-in Diagnose and solve problems / Diagnostics and Troubleshooting quickly pointed to an error spike in PHP logs for the past 24 hours:

PHP Fatal error: Class 'Twig_Loader_Filesystem' not found

Or variants of the same in PHP Log Analyzer / PHP Error Log Processing Report:

Class 'Twig_Loader_Filesystem' not found in D:\home\site\wwwroot\wp-content\plugins\gallery-by-supsystic\vendor\Rsc\Environment.php on line 171

After PHP update:

Uncaught Error: Class 'Twig_Loader_Filesystem' not found in D:\home\site\wwwroot\wp-content\plugins\gallery-by-supsystic\vendor\Rsc\Environment.php:171

(Note that you need to re-run "Collect PHP Error Logs" each time you want to validate if a change resolved your issue or got you to the next issue to investigate.)

Not clear why this started failing now. Web search lead me to https://twig.symfony.com/doc/2.x/intro.html#installation

Apparently I needed newer PHP in the first place to run Twig. My PHP in the Application Settings was at 5.6 so I jumped to 7.2. That wasn't enough of course, just a pre-req.

Then I needed Composer as installation mechanism. I found it in the App Service Extensions inside the portal. A restart of the App Service and some wait time was required before Composer started working in the Kudu console (I used the PowerShell version of the console).

<pending screenshot of extensions with composer>

The default start folder for the Kudu console doesn't work for Twig installation due to permission denied. I navigated just under site then (I'm unsure if that's the right place to install it, expert recommendation welcome).

PS D:\home\site>>composer require "twig/twig:^2.0"


./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-mbstring (v1.7.0): Downloading (connecting...)Downloading (0%)           Downloading (20%)Downloading (40%)Downloading (45%)Downloading (65%)Downloading (85%)Downloading (90%)Downloading (100%)
  - Installing twig/twig (v2.0.0): Downloading (connecting...)Downloading (100%)         
Writing lock file
Generating autoload files
The blog site was however still failing with 500 Internal Server Error. PHP logs are still showing the same error.
I tried returning to PHP 5.6 and install Twig 1.x instead. Composer appeared to nicely support the downgrade. No dice on accessing the blog 'though.
Found this which appears to be the company developing the WordPress plugin: https://supsystic.com/plugins/photo-gallery
By deleting gallery-by-supsystic (using Kudu console again) I regained access to both blog and admin page. If I uploaded it again, back to 500, even 'though the help page says the plugin should be disabled.
Time to post a support question to this plugin developer.
Comments (0)

Skip to main content