Frameworks
Symfony — Intégration Scell.io
Bundle Symfony via SDK PHP + ContainerInterface
Le SDK PHP `scell/sdk` v3.5.0 s'utilise dans Symfony via injection de service. Déclarer le client comme service dans `services.yaml`, l'injecter dans les controllers/services via autowiring. Compatible Symfony 6 et 7, support des Messenger handlers pour traitement asynchrone, intégration native avec le composant HttpClient Symfony.
À retenir
- Installation : `composer require scell/sdk`
- Service déclaré dans `config/services.yaml`
- Injection via autowiring (constructor)
- Compatible Symfony Messenger pour async
- Support des secrets vault Symfony
Exemple de code
// config/services.yaml : Scell\Sdk\Client: { arguments: ['%env(SCELL_API_KEY)%'] }
use Scell\Sdk\Client as ScellClient;
class InvoiceController extends AbstractController
{
public function __construct(private ScellClient $scell) {}
#[Route('/invoice', methods: ['POST'])]
public function create(): JsonResponse
{
$invoice = $this->scell->invoices()->builder()
->facturX()
->addLine('Audit', 1, 2000.00, 20.0)
->create();
return $this->json(['id' => $invoice->id]);
}
}