Install snappybundle symfony4

831 views Asked by At

I have an installation problem with SnappyBundle on Symfony 4.
Indeed, I proceeded like this tutoriel : Tutoriel.

I followed the tutorial to the letter, I realized by testing the console, before making the controller with :
php bin/console

But I have an error, after setting up the configuration. Here is the message:

Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "KnpSnappyBundle" from namespace "Knp\Bundle\SnappyBundle". Did you forget a "use" statement for another namespace? in /Applications/MAMP/htdocs/projet/src/Kernel.php:33

Stack trace:
0 /Applications/MAMP/htdocs/projet/vendor/symfony/http-kernel/Kernel.php(409): App\Kernel-> registerBundles ()
1 /Applications/MAMP/htdocs/projet/vendor/symfony/http-kernel/Kernel.php(120): Symfony\Component\HttpKernel\Kernel-> initializeBundles ()
2 /Applications/MAMP/htdocs/project/vendor/symfony/framework-bundle/Console/Application.php(65): Symfony\Component\HttpKernel\Kernel-> boot ()
3 /Applications/MAMP/htdocs/project/vendor/symfony/console/Application.php(145): Symfony\Bundle\FrameworkBundle\Console\Application-> doRun (Object (Symfony\Component\Console\Input\ArgvInput), Object (Symfony\Component\Console\Output\ConsoleOutput))
4 / Applications/MAMP/htdocs/project/bin/console (39 in /Applications/MAMP/htdocs/projet/src/Kernel.php on line 33

I did add the bundle to the file /config/packages/bundles.php

Knp\Bundle\SnappyBundle\KnpSnappyBundle :: class => ['all' => true],

Most of the topics on Snappy are discussed with Symfony 3, except the problem here comes from the Symfony kernel, but why, I do not understand. Thanks for your help

2

There are 2 answers

2
JochenJung On BEST ANSWER

You should import the SnappyBundle at the beginning of your controller.

For example:

use Knp\Bundle\SnappyBundle\Snappy\Response\Response;
0
devFanch On

I capitulated, rather than using snappy, I will try with dompdf, which looks very good and easier to set up. solved: Github thanks for all