I updated a Symfony project from 4.4 to 5.4. First I was going to 5.0, add some fixes and checked the project. It worked well. Then I was going to 5.4. Now I get the message that "is_granted" is unknown in twig. Security-Bundle is installed and also loaded via bundles.php.
The security.yaml:
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
encoders:
App\Entity\Benutzer:
algorithm: bcrypt
providers:
app_user_provider:
entity:
class: App\Entity\Benutzer
property: loginname
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true
guard:
authenticators:
- App\Security\LoginFormAuthenticator
logout:
path: app_logout
# where to redirect after logout
# target: app_any_route
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#firewalls-authentication
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
# - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
composer.json:
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.2.5",
"ext-ctype": "*",
"ext-gd": "^7.3",
"ext-iconv": "*",
"beberlei/doctrineextensions": "v1.2.6",
"doctrine/annotations": "^1.8",
"doctrine/doctrine-bundle": "^2",
"doctrine/doctrine-migrations-bundle": "^2",
"doctrine/orm": "^2",
"sensio/framework-extra-bundle": "^5.5",
"symfony/apache-pack": "^1.0",
"symfony/asset": "5.4.*",
"symfony/console": "5.4.*",
"symfony/doctrine-bridge": "5.4.*",
"symfony/dotenv": "5.4.*",
"symfony/expression-language": "5.4.*",
"symfony/flex": "^1.3.1",
"symfony/form": "5.4.*",
"symfony/framework-bundle": "5.4.*",
"symfony/mailer": "5.4.*",
"symfony/security-bundle": "5.4.*",
"symfony/security-core": "5.4.*",
"symfony/serializer": "5.4.*",
"symfony/swiftmailer-bundle": "^3.4",
"symfony/twig-bridge": "5.4.*",
"symfony/validator": "5.4.*",
"symfony/yaml": "5.4.*"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3",
"symfony/maker-bundle": "*",
"symfony/stopwatch": "5.4.*",
"symfony/twig-bundle": "5.4.*",
"symfony/web-profiler-bundle": "5.4.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.4.*"
}
}
}
Does anyone have an idea what's wrong or an hint how to debug this?
Thanks!
Alex
@Cerad Thank you very much. That was the problem. I compared the composer.json files and added the missing Twing packages.
Also there was a delta between local files and the files on the server. Removing the vendor folder on server and upload the one from the local environment in combination withe the tip from Cerad fixed all problems.
In symfony 5.4 you have to install "twig/extra-bundle" manually. It should resolve the issue with
composer require twig/extra-bundle
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.