PHP code example of 2rius / dart-transformer

1. Go to this page and download the library: Download 2rius/dart-transformer 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/ */

    

2rius / dart-transformer example snippets




namespace App\Data;

use Spatie\LaravelData\Data;

class UserData extends Data
{
    public function __construct(
        public int $id,
        public string $name,
        public ?string $email,
        public bool $isActive
    ) {}
}



namespace App\Enums;

enum Status: string
{
    case ACTIVE = 'active';
    case INACTIVE = 'inactive';
    case PENDING = 'pending';
}

'dart' => [
    'naming_strategy' => \M2rius\DartTransformer\Naming\FqcnUnderscoredNamingStrategy::class,
],
bash
php artisan vendor:publish --tag="dart-transformer-config"
bash
php artisan dart:transform