Troubling setting Kirby "Class 'Twig\Loader\FilesystemLoader' not found" error

Hi everyone,
I have had a website running on Kirby 2 for time now and decided the update was long overdue. My site is using the Baltrum theme and it works fine online as of today.

I decided to work on my site locally, and failed to update the existing website to Kirby 3 - I decided it was probably because of the old theme and settled to start over a new project.

I have downloaded the starter kit, plus a free theme (the Lemmon Portfolio). I copied the Kirby files to the theme file, as well as the index. I have tried multiples copies (with or without hidden files, etc.) but I always end up with a MAMP error screen stating “Class ‘Twig\Loader\FilesystemLoader’ not found” when I try to access the site. I have test the starter kit on its own and it works.

This line in particular seems to be the culprit - I am by no means a professional developer and there is not much I can do on my own (the link looks fine to me, pointing to the ‘templates’ folder, which exists in the described location):
$loader = new Twig\Loader\FilesystemLoader(__DIR__ . '/../../templates');

If anyone could give me pointers, it would be much appreciated. I picked Kirby 2 back then because it was so simple to put together, but I must say I’m having a hard time with Kirby 3.

all the best

Did you follow the instruction in the readme of the theme, re installing dependencies via composer?

I guess not, because the dependencies are missing, hence the error.

Thank you for this quick reply!

I actually missed that part - so I tried to run composer install in my root folder, which returns composer: command not found

I tried installing composer using this tutorial, but the error message is the same after I run composer install. The error message is the same on MAMP.

Here is a summary of what I have done:

  • copy the template file, renaming it mywebsite
  • copy the kirby folder inside mywebsite
  • tried to run composer install in mywebsite > and failed
  • composer diagnose returns the same error message
    - php composer diagnose returns Could not open input file: composer

Side note: I created a shell (sh-3.2$) for a different project which was necessary to work with Jekyll… I don’t know if that can be an issue or how to work around that.

Many thanks!

What you should do is exactly follow the instructions without any additional steps:

  • Either download the theme files or clone it via git
  • cd into the folder
  • run composer install

Don’t put the kirby folder into the downloaded stuff, composer does this for you.

I just tested it myself and works.

Hi and thank you for the swift reply…
I followed the steps required but still got the same error message. However I found a Stack Overflow thread which solved my Composer problem. I’m reporting it here in case someone hits the same snafu.
Here is the code :

$ curl -sS | php
$ chmod +x composer.phar
$ mv composer.phar /usr/local/bin/composer
$ composer

thanks again for the help!