After update from Symfony 2.2 to Symfony 3.4 I get error
The "knp_snappy.pdf" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
config.yml
knp_snappy:
pdf:
enabled: true
binary: '%knp_snappy_pdf_binary%'
options: []
in controller action:
$html = $this->renderView(
'FsaBundle:Registration:registrationEmail.html.twig', ['data' => $data]
);
$pdf = $this->get('knp_snappy.pdf')->getOutputFromHtml($html);
...
How to make knp_snappy.pdf
public?
Upgrade KnpSnappyBundle
to 1.5.2: they've done it for you.
In case you're redefining the service (which should be useless), put the public: true
in the definition.
Moreover, put ^1.5
as the version in composer.json
in order to receive all compatible upgrades (< 2
) of this bundle (and I would recommend to do so for every third party code that follows the semantic versioning) during a composer update
If you would like to know more about composer and its constraints, checkout the ^
(caret) documentation.