You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 4, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 4, 2026. It is now read-only.
I try to understand where the $validator object comes from in src/Contact/ContactController.php
use Yiisoft\Validator\ValidatorInterface;
...
final class ContactController
{
...
public function contact(
ValidatorInterface $validator,
ServerRequestInterface $request
): ResponseInterface {
}
The action contact is defined in ./config/routes.php:
return [
// Lonely pages of site
Route::get('/')
->action([SiteController::class, 'index'])
->name('site/index'),
Route::methods([Method::GET, Method::POST], '/contact')
->action([ContactController::class, 'contact'])
->name('site/contact'),
...
But there is no link to any Validator defined nor any injection of an ValidatorInterface or a model class.
Activity
samdark commentedon Dec 30, 2021
Yes, it's a new concept if you haven't used DI container in Yii2 (there it was optional). Here you go: https://github.com/yiisoft/docs/blob/master/guide/en/concept/di-container.md It's a draft documentation but, I think, explains it well.