Bonjour,
dans une application symfony j'ai intallé HTML2PDF 5.2 pour editer des factures.
J'ai installé un service HTML2PDF comme suit:
<?php
namespace App\Service;
class HTML2PDF
{
public $pdf;
/**
* @param null $orientation
* @param null $format
* @param null $lang
* @param null $unicode
* @param null $encoding
* @param null $margin
*/
public function create(
$orientation = null,
$format = null,
$lang = null,
$unicode = null,
$encoding = null,
$margin = null
): void {
$this->pdf = new \HTML2PDF(
$orientation ? $orientation : $this->orientation,
$format ? $format : $this->format,
$lang ? $lang : $this->LANG,
$unicode ? $unicode : $this->unicode,
$encoding ? $encoding : $this->encoding,
$margin ? $margin : $this->margin
);
$this->pdf->SetDisplayMode('fullpage');
}
/**
* @param $template
* @param $name
* @return mixed
*/
public function generatePdf($template, $name)
{
$this->pdf->writeHTML($template);
return $this->pdf->Output($name.'.pdf');
}
}
phpStorm me met un warning sur les methodes SetDisplayMode, SetDisplayMode et output ,Method 'SetDisplayMode' not found in \HTML2PDF less... et un warning sur new \HTML2PDF , pour Undefined class HTML2PDF.
Ce qui montre bien que la classe n'est pas chargée.
Pourtant elle est bien dans mes services:
services:
...
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
App.html2pdf:
class: App\Service\HTML2PDF
...
L'autowiring est activé
Le petit test que j'ai mis dans un controller confime que l'on accède pas à la classe.
php bin/console debug:container 'App\Service\HTML2PDF' --show-arguments renvoie:
Information for Service "App\Service\HTML2PDF"
Option Value
Service ID App\Service\HTML2PDF
Class App\Service\HTML2PDF
Tags -
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired yes
Autoconfigured yes
Quelle est la syntaxe de la configutation du service qui empeche de charger la classe HTML2PDF dans symfony?
Merci de votre aide