fusio / adapter-symfony
Integrates features of the symfony framework
Fund package maintenance!
chriskapp
Patreon
www.paypal.me/fusioapi
Requires
- php: >=8.0
- doctrine/orm: ^2.7
- fusio/engine: ^5.0
- jms/serializer: ^3.4
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-11-03 19:24:10 UTC
README
Fusio adapter which helps to integrate features of Symfony. You can install the adapter with the following steps inside your Fusio project:
composer require fusio/adapter-symfony
php bin/fusio system:register "Fusio\Adapter\Symfony\Adapter"
Configuration
All your entities needs to be placed inside the folder src/Entity
since the
Doctrine connection checks only this folder.
Example
Through the Doctrine connection you can build API endpoints using the Doctrine ORM i.e.:
<?php namespace App\Action; use Fusio\Engine\ActionAbstract; use Fusio\Engine\ContextInterface; use Fusio\Engine\ParametersInterface; use Fusio\Engine\RequestInterface; use JMS\Serializer\SerializerBuilder; class Messages extends ActionAbstract { public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context) { /** @var \Doctrine\ORM\EntityManager $entityManager */ $entityManager = $this->connector->getConnection('doctrine'); /** @var \JMS\Serializer\ArrayTransformerInterface $serializer */ $serializer = SerializerBuilder::create()->build(); $dql = "SELECT m FROM App\Entity\Message m ORDER BY m.id DESC"; $query = $entityManager->createQuery($dql); $messages = $query->getResult(); $result = []; foreach ($messages as $message) { $result[] = $serializer->toArray($message); } return $this->response->build(200, [], [ 'messages' => $result, ]); } }