PHP code example of omerkoseoglu / devextreme-data-symfony

1. Go to this page and download the library: Download omerkoseoglu/devextreme-data-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/ */

    

omerkoseoglu / devextreme-data-symfony example snippets


DevExtreme\Data\Symfony\DevExtremeDataBundle::class => ['all' => true],

use DevExtreme\Data\Symfony\DevExtremeLoader;
use DevExtreme\Data\Symfony\Doctrine\EntitySource;

#[Route('/api/orders')]
public function orders(DevExtremeLoader $loader, EntityManagerInterface $em): JsonResponse
{
    return $loader->response(EntitySource::for($em, Order::class, where: 'deleted_at IS NULL'));
}

public function load(LoadOptions $options): JsonResponse { /* $options->take, ->filter, ... */ }

$qb = $connection->createQueryBuilder()
    ->select('o.id', 'o.total', 'c.name AS customer_name')
    ->from('orders', 'o')->join('o', 'customers', 'c', 'c.id = o.customer_id')
    ->where('o.tenant_id = :tenant')->setParameter('tenant', $tenantId);

$source = DbalSource::forQueryBuilder($connection, $qb,
    columns: ['id' => 'id', 'total' => 'total', 'customer.name' => 'customer_name', 'gross' => new Raw('total * 1.2')],
    primaryKey: ['id'],
);
yaml
devextreme_data:
    normalize_dates: true   # compare ISO-8601 filter dates as wall-clock time in SQL
    max_take: ~             # cap rows per request (null = unlimited; leave null for PivotGrid endpoints)