Closed
Description
Symfony version affected: 5.0.5
Description
Could not resolve argument $authenticationUtils of "App\Controller\SecurityController:login()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
How to reproduce
- Install these dependencies:
composer show -i
:
doctrine/annotations v1.8.0 Docblock Annotations Parser
doctrine/cache 1.10.0 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.
doctrine/collections 1.6.4 PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common 2.12.0 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, persistence interfaces, proxies, event syste...
doctrine/dbal v2.10.1 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/doctrine-bundle 2.0.7 Symfony DoctrineBundle
doctrine/doctrine-migrations-bundle 2.1.2 Symfony DoctrineMigrationsBundle
doctrine/event-manager 1.1.0 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector 1.3.1 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator 1.3.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer 1.2.0 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations 2.2.1 PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very ea...
doctrine/orm v2.7.1 Object-Relational-Mapper for PHP
doctrine/persistence 1.3.6 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/reflection v1.1.0 The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional functionality on top of the reflection functionality that comes with PHP. It allo...
easycorp/easy-log-handler v1.0.9 A handler for Monolog that optimizes log messages to be processed by humans instead of software. Improve your productivity with logs that are easy to understand.
easycorp/easyadmin-bundle v2.3.5 Admin generator for Symfony applications
jdorn/sql-formatter v1.2.17 a PHP SQL highlighting library
monolog/monolog 2.0.2 Sends your logs to files, sockets, inboxes, databases and various web services
nikic/php-parser v4.3.0 A PHP parser written in PHP
ocramius/package-versions 1.5.1 Composer plugin that provides efficient querying for installed package versions (no runtime IO)
ocramius/proxy-manager 2.2.3 A library providing utilities to generate, instantiate and generally operate with Object Proxies
pagerfanta/pagerfanta v2.1.3 Pagination for PHP
psr/cache 1.0.1 Common interface for caching libraries
psr/container 1.0.0 Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher 1.0.0 Standard interfaces for event handling.
psr/log 1.1.2 Common interface for logging libraries
symfony/asset v5.0.4 Symfony Asset Component
symfony/browser-kit v5.0.4 Symfony BrowserKit Component
symfony/cache v5.0.4 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts v2.0.1 Generic abstractions related to caching
symfony/config v5.0.5 Symfony Config Component
symfony/console v5.0.4 Symfony Console Component
symfony/css-selector v5.0.4 Symfony CssSelector Component
symfony/debug-bundle v5.0.4 Symfony DebugBundle
symfony/debug-pack v1.0.7 A debug pack for Symfony projects
symfony/dependency-injection v5.0.5 Symfony DependencyInjection Component
symfony/doctrine-bridge v5.0.4 Symfony Doctrine Bridge
symfony/dom-crawler v5.0.4 Symfony DomCrawler Component
symfony/dotenv v5.0.4 Registers environment variables from a .env file
symfony/error-handler v5.0.5 Symfony ErrorHandler Component
symfony/event-dispatcher v5.0.5 Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v2.0.1 Generic abstractions related to dispatching event
symfony/expression-language v5.0.4 Symfony ExpressionLanguage Component
symfony/filesystem v5.0.5 Symfony Filesystem Component
symfony/finder v5.0.4 Symfony Finder Component
symfony/flex v1.6.2 Composer plugin for Symfony
symfony/form v5.0.4 Symfony Form Component
symfony/framework-bundle v5.0.4 Symfony FrameworkBundle
symfony/http-client v5.0.4 Symfony HttpClient component
symfony/http-client-contracts v2.0.1 Generic abstractions related to HTTP clients
symfony/http-foundation v5.0.5 Symfony HttpFoundation Component
symfony/http-kernel v5.0.5 Symfony HttpKernel Component
symfony/inflector v5.0.5 Symfony Inflector Component
symfony/intl v5.0.4 A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/maker-bundle v1.14.3 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/mime v5.0.5 A library to manipulate MIME messages
symfony/monolog-bridge v5.0.4 Symfony Monolog Bridge
symfony/monolog-bundle v3.5.0 Symfony MonologBundle
symfony/options-resolver v5.0.5 Symfony OptionsResolver Component
symfony/orm-pack v1.0.8 A pack for the Doctrine ORM
symfony/phpunit-bridge v5.0.4 Symfony PHPUnit Bridge
symfony/polyfill-intl-icu v1.14.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn v1.14.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring v1.14.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php73 v1.14.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/profiler-pack v1.0.4 A pack for the Symfony web profiler
symfony/property-access v5.0.5 Symfony PropertyAccess Component
symfony/routing v5.0.4 Symfony Routing Component
symfony/security-bundle v5.0.4 Symfony SecurityBundle
symfony/security-core v5.0.4 Symfony Security Component - Core Library
symfony/security-csrf v5.0.4 Symfony Security Component - CSRF Library
symfony/security-guard v5.0.4 Symfony Security Component - Guard
symfony/security-http v5.0.4 Symfony Security Component - HTTP Integration
symfony/service-contracts v2.0.1 Generic abstractions related to writing services
symfony/stopwatch v5.0.4 Symfony Stopwatch Component
symfony/test-pack v1.0.6 A pack for functional and end-to-end testing within a Symfony app
symfony/translation v5.0.4 Symfony Translation Component
symfony/translation-contracts v2.0.1 Generic abstractions related to translation
symfony/twig-bridge v5.0.4 Symfony Twig Bridge
symfony/twig-bundle v5.0.4 Symfony TwigBundle
symfony/twig-pack v1.0.0 A Twig pack for Symfony projects
symfony/validator v5.0.4 Symfony Validator Component
symfony/var-dumper v5.0.4 Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter v5.0.4 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-profiler-bundle v5.0.4 Symfony WebProfilerBundle
symfony/yaml v5.0.4 Symfony Yaml Component
twig/extra-bundle v3.0.3 A Symfony bundle for extra Twig extensions
twig/twig v3.0.3 Twig, the flexible, fast, and secure template language for PHP
zendframework/zend-code 3.4.1 Extensions to the PHP Reflection API, static code scanning, and code generation
zendframework/zend-eventmanager 3.2.1 Trigger and listen to events within a PHP application
composer.json
:
"require": {
"php": "^7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"easycorp/easyadmin-bundle": "^2.3",
"myclabs/php-enum": "^1.7",
"symfony/console": "5.0.*",
"symfony/dotenv": "5.0.*",
"symfony/flex": "^1.3.1",
"symfony/form": "5.0.*",
"symfony/framework-bundle": "5.0.*",
"symfony/http-client": "5.0.*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "*",
"symfony/security-bundle": "5.0.*",
"symfony/twig-pack": "*",
"symfony/validator": "5.0.*",
"symfony/yaml": "5.0.*"
},
"require-dev": {
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/profiler-pack": "^1.0",
"symfony/test-pack": "*"
}
<?php
declare(strict_types=1);
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
public function login(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render(
'security/login.html.twig',
[
'last_username' => $lastUsername,
'error' => $error
]
);
}
}
- Add route:
# routes/security.yaml
login:
controller: App\Controller\SecurityController:login
path: login
methods: GET|POST
- Enable login in
firewalls
config:
firewalls:
# ...
main:
anonymous: lazy
form_login:
login_path: login
check_path: login
- Keep
services.yml
by default:
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
- Navigate to
/login
route
Possible Solution
Do not break BC between patch/minor versions
Additional context
5.0.4 is not affected