Answer the question
In order to leave comments, you need to log in
Why is there an error when transferring the service to the controller parameters?
Tell me why an error occurs when transferring the service to the controller parameters?
use App\Service\CustomService;
// где "...." - в этом месте еще куча разных сервисов подключаются, но они работают
public function index(...., CustomService $customService): Response
{
$telegramBot = new \TelegramBot\Api\Client($bot->getToken());
// logic
$telegramBot->on(function (\TelegramBot\Api\Types\Update $update) use ($telegramBot, $customService) {
$customService->customMethod(
$parametr1 = '...',
$parametr2 = '...',
$parametr3 = '...',
);
}, function () {
return true;
});
}
request.CRITICAL: Uncaught PHP Exception RuntimeException: "Controller "App\Controller\TestController::index()" requires that you provide a value for the "$customService" 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." at /var/www/project/vendor/symfony/http-kernel/Controller/ArgumentResolver.php line 80 {"exception":"[object] (RuntimeException(code: 0): Controller \"App\\Controller\\TestController ::index()\" requires that you provide a value for the \"$customService\" 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.
Answer the question
In order to leave comments, you need to log in
index(...., CustomService $customService)what version of php does this work in?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question