I'm a newbie on Symfony and I'm having a problem to integrate the 'ry167/twig-gravatar' package on my project.
First, I did :
$ composer require ry167/twig-gravatar 3.0.0
And after I modified my services.yaml, which looks like this :
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
twig.extension.gravatar:
class: \TwigGravatar
arguments:
$default: ~ e.g. 'monsterid'
$size: ~ e.g. 50
$filterPrefix: ~ e.g. 'foo'
$rating: ~ e.g. 'x'
$useHttps: true
tags:
- { name: twig.extension }
And finally, I have this on my view:
<p>{{ '[email protected]'|grAvatar }}</p>
But I got this error:
Invalid service "twig.extension.gravatar": class "Twig_Extension" not found while loading "TwigGravatar"
Any ideas? I can't understand where my problem comes from...
You probably use Twig 3.* which removed all PSR-0 classes (with the underscore).
The next version of
ry167/twig-gravatarfixes the issue. There is already a release candidate.Option 1: Wait for next stable release
If you want to wait for the stable release, then temporarily add a
conflictblock to yourcomposer.jsonto use the latest Twig version before 3.0:Run
composer updateafterwards to let Composer do the work of figuring out the dependencies and downgrading your Twig version.You may remove the
conflictwhen version 4.0 is released and you changed the dependency to^4.0.0.Option 2: Use Release Candidate
If you want to use the new version right away, you have to tell composer that non-stable versions are alright using stability flags.