<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
loophp / service-alias-autoregister-bundle example snippets
declare(strict_types=1);
namespace App\Controller;
use App\Repository\UserRepository;
final class MyTestController
{
// Here we inject a concrete implementation of a Doctrine repository.
public function __invoke(UserRepository $userRepository): Response
{
// Do stuff.
}
}
declare(strict_types=1);
namespace App\Controller;
use Doctrine\Persistence\ObjectRepository;
final class MyTestController
{
// Here we inject the UserRepository (which implements ObjectRepository)
// using the variable which has been created from the UserRepository class name.
public function __invoke(ObjectRepository $userRepository): Response
{
// Do stuff.
}
}
declare(strict_types=1);
namespace App\Controller;
use App\Repository\UserRepository;
use Doctrine\Persistence\ObjectRepository;
final class MyTestController
{
private UserRepository $userRepository;
public function __construct(ObjectRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function __invoke(): Response
{
// Do stuff.
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.