Can't install Twig Extensions on OC v3.0.66

I’m trying to install the Twig Extensions plugin with:

php artisan plugin:install vojtasvoboda.twigextensions

It throws this error:

Problem 1
    - vojtasvoboda/twigextensions-plugin[dev-master, 1.3.1, ..., 1.x-dev] require symfony/translation ^3.4 || ^4.0 -> found symfony/translation[v3.4.0-BETA1, ..., 3.4.x-dev, v4.0.0-BETA1, ..., 4.4.x-dev] but the package is fixed to v6.1.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - vojtasvoboda/twigextensions-plugin[1.2.0, ..., 1.3] require symfony/translation ~3.3.9 -> found symfony/translation[v3.3.9, ..., 3.3.x-dev] but the package is fixed to v6.1.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - vojtasvoboda/twigextensions-plugin[dev-laravel54, 1.0.7, ..., 1.1.3] require symfony/translation 2.7.* -> found symfony/translation[v2.7.0-BETA1, ..., 2.7.x-dev] but the package is fixed to v6.1.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - vojtasvoboda/twigextensions-plugin[1.0.1, ..., 1.0.6] require symfony/translation ^3.0 -> found symfony/translation[v3.0.0-BETA1, ..., 3.4.x-dev] but the package is fixed to v6.1.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires vojtasvoboda/twigextensions-plugin * -> satisfiable by vojtasvoboda/twigextensions-plugin[dev-master, dev-laravel54, 1.0.1, ..., 1.x-dev].

I probably can’t just downgrade symfony/translation to ^4.0. I guess, this will brake stuff.

I may do now a fork of GitHub - vojtasvoboda/oc-twigextensions-plugin: Twig extensions plugin for OctoberCMS and try to set symfony/translation dependency to ^6.0 and see if it still works.

A lot of the extensions that were apart of that package are not now apart of OCS v3. You may be able to get away without it.

Edit (wrong word)

Very true. And I also just saw, that things like e.g. wordwrap or truncate can be done in Twig v3.x with 'Lorem ipsum'|u.wordwrap(5) or 'Lorem ipsum'|u.truncate(8, '...') repectively.

I still try to fix it, because I need it in a lot of my projects and I like to have array|shuffle.

1 Like

Not 100% sure but you can do that with the new Query builder in twig.

something like {% set collection = collection.shuffle() %}

OC3 has the query builder built in, but I could be wrong that this exists.

Thanks, but I already did a PR for the Twig Extension plugin. But I couldn’t re-implement all of the filters, because of precious time :wink:

Also I have an array to shuffle. Would {% set collection = collection.shuffle() %} also work with plain array instead of collections?

And then I find it convenient to just write 'My string'|truncate(5) instead of adding the u :man_shrugging:. Moreover if this plugin doesn’t work on OC v3.x, I would need to refactor a lot of my projects after updating…

1 Like

Ahh I see where you’re coming from.

I’m not sure if that would work on a simple array since that function uses Laravel’s eloquent lookup, but I’d try it to see if can. Probably won’t work tho.

and yeah it’s simpler to write that. I personally don’t like installing plugins as much as possible and I only like to use what I need.