Afficher fichier pdf sous symfony 4.2.8 ( migration symfony 3 vers symfony 4)
Bonjour,
J'ai migré mon projet sous Symfony 3.3.6 vers Symfony 4.2.8 et j'ai mon fichier pdf (mon cv ) qui ne s'affiche pas ! L'erreur :
Citation:
Service "kernel" not found: even though it exists in the app's container, the container inside "App\Controller\MoncvController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Try using dependency injection instead.
J'ai essayé à maintes reprises de trouver la solution via le web mais en vain ! Alors je me tourne vers vous pour trouver des idées.
Mon controller :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
// Import the BinaryFileResponse
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class MoncvController extends AbstractController
{
/**
* @Route("/moncv", name="moncv")
*/
public function index()
{
// i.e Sending a file from the resources folder in /web
// in this example, the TextFile.txt needs to exist in the server
$publicResourcesFolderPath = $this->get('kernel')->getRootDir() . '/../public/images/';
$filename = "moncv.pdf";
// This should return the file located in /mySymfonyProject/web/public-resources/TextFile.txt
// to being viewed in the Browser
return new BinaryFileResponse($publicResourcesFolderPath.$filename);
;
}
} |
Merci d'avance .