Eu fiz esse código aqui, passando como argumento o ID do curso.
<?php
use Alura\Cursos\Infra\EntityManagerCreator;
use Alura\Cursos\Entity\Curso;
require __DIR__ . '/../vendor/autoload.php';
$fabrica = new EntityManagerCreator();
$entidadeFabrica = $fabrica->getEntityManager();
$cursos = $entidadeFabrica->getRepository(Curso::class);
$id = $argv[1];
$deletar = $entidadeFabrica->getReference(Curso::class, $id);
$entidadeFabrica->remove($deletar);
$entidadeFabrica->flush();
Mas ocorre este erro não consegui identificar o problema,
PHP Warning: require(C:\Users\rlirio\AppData\Local\Temp\__CG__AluraCursosEntityCurso.php): Failed to open stream: No such file or directory in C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php on line 198
Warning: require(C:\Users\rlirio\AppData\Local\Temp\__CG__AluraCursosEntityCurso.php): Failed to open stream: No such file or directory in C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php on line 198
PHP Fatal error: Uncaught Error: Failed opening required 'C:\Users\rlirio\AppData\Local\Temp\__CG__AluraCursosEntityCurso.php' (include_path='.;C:\php\pear') in C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php:198
Stack trace:
#0 C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php(109): Doctrine\Common\Proxy\AbstractProxyFactory->getProxyDefinition('Alura\\Cursos\\En...')
#1 C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(538): Doctrine\Common\Proxy\AbstractProxyFactory->getProxy('Alura\\Cursos\\En...', Array)
#2 C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\public\delete.php(15): Doctrine\ORM\EntityManager->getReference('Alura\\Cursos\\En...', Array)
#3 {main}
thrown in C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php on line 198
Fatal error: Uncaught Error: Failed opening required 'C:\Users\rlirio\AppData\Local\Temp\__CG__AluraCursosEntityCurso.php' (include_path='.;C:\php\pear') in C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php:198
Stack trace:
#0 C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php(109): Doctrine\Common\Proxy\AbstractProxyFactory->getProxyDefinition('Alura\\Cursos\\En...')
#1 C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(538): Doctrine\Common\Proxy\AbstractProxyFactory->getProxy('Alura\\Cursos\\En...', Array)
#2 C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\public\delete.php(15): Doctrine\ORM\EntityManager->getReference('Alura\\Cursos\\En...', Array)
#3 {main}
thrown in C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php on line 198
C:\Users\rlirio\Documents\Cursos-Alura\PHP\MVC\public>