1. Go to this page and download the library: Download morphql/morphql-symfony library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use MorphQL\SymfonyBundle\TransformationRegistry;
class InvoiceService
{
public function __construct(
private readonly TransformationRegistry $registry
) {}
public function process(array $data): string
{
// Resolves to morphql-queries/invoices/to_xml.morphql
return $this->registry->transform('invoices/to_xml', $data);
}
}
use MorphQL\MorphQL;
class MyController
{
public function __construct(
private readonly MorphQL $morphql
) {}
public function index(string $json): string
{
return $this->morphql->run('from json to json transform set x = 1', $json);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.