I have recently bought a new computer. Both old and new have xampp over Windows 10. After I have copied all my apache, mysql and php configuration files to the new one and once checked everything can run. I find an error on one of my symfony sites homepage using exactly the same files I was using previously.
Controller “AppControllerFrontendController::index()” requires that
you provide a value for the “$locale” argument. Either the argument is
nullable and no null value has been provided, no default value has
been provided or because there is a non optional argument after this
one.
In order to check for the possible error I have created a new FrontendController class with the minimal code I needed in order to reproduce my error.
Here is the code that does not generate the error:
<?php
namespace AppController;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentRoutingAnnotationRoute;
class FrontendController extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function index(
Request $request,
string $locale = 'es'
) {
dd($locale);
}
}
Here is the code that DOES generate the error. The only difference is that I add WhiteOctober/BreadcrumbsBundle that works like a charm in my installation on the previous computer.
<?php
namespace AppController;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentRoutingAnnotationRoute;
use WhiteOctoberBreadcrumbsBundleModelBreadcrumbs;
class FrontendController extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function index(
Request $request,
string $locale = 'es',
Breadcrumbs $breadcrumbs
) {
dd($locale);
}
}
Again, when I remove $locale from the parameters list, things also work:
<?php
namespace AppController;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentRoutingAnnotationRoute;
use WhiteOctoberBreadcrumbsBundleModelBreadcrumbs;
class FrontendController extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function index(
Request $request,
Breadcrumbs $breadcrumbs
) {
dd("Without locale");
}
}