Closed nunocodex closed 8 years ago
On the technical side:
You mean loading vendor/autoload.php
in a try/catch, silencing the error, then checking if the Twig_Environment
class exists?
Or do you mean that some people may be using Composer already and may add Twig to their project's requirements?
On the use case side:
What is the use case for this kind of change?
Right now it seems very few people are using Composer to install Kirby, since it's not supported out of the box and you have to write your own mappings.
Thanks for your input, it's much appreciated. :)
I think instead to check if the autoload.php file exists you can check if the twig class exists in the try/catch. This leave all 2 way you mentioned before.
Reading much better you can check before the twig class, if not exists check the autoload, is the best way i can thinking.
I'm not 100% sure how that would look. Can you write a code example here or submit a pull request?
No problem I added a PR https://github.com/fvsch/kirby-twig/pull/5
Fixed in https://github.com/fvsch/kirby-twig/commit/6c43d747b52d9c9bf0c3201f2926db2f4929d7d0
I also renamed the main class from TwigComponent
to KirbyTwigComponent
. Since Twig uses Twig_*
, it was probably low risk but still confusing to use TwigComponent
.
In the end I see you check the composer autoload but I think the best way is check if the Twig class exists.