Hej, jak w Symfony 4 mogę wstrzyknąć Entity Menager w klasę?
mój serwis wygląda tak:
appBundle/service/ClassService.php
class ClassService
{
public function __construct(EntityManagerInterface $entityManager)
{
$this->em = $entityManager;
}
}
Mój kontroler:
appBundle/Controller/HomeController.php
class HomeController extends Controller
{
/**
* @Route("/home", name="home")
*/
public function index(Request $request, ClassService $classService)
{
$classService = new ClassService();
//...
}
}
dostaje error:
The autoloader expected class "App\Service\ClassService" to be defined in file "C:\xampp\htdocs\symfony\vendor\composer/../../src\Service\ClassService.php". The file
was found but the class was not in it, the class name or namespace probably has a typo in C:\xampp\htdocs\symfony\config/services.yaml (which is loaded in resource "C:\xampp\ht
docs\symfony\config/services.yaml").
czytałem, że trzeba skonfigurować services.yaml jednak niedziała lub źle to robię:(
pomoże ktoś?
chciałbym korzystać z Entity Menagera w mojej klasie ClassService, a gdy utworze obiekt tej klasy w Controllerze żebym nie musiał tam ładować nic:)