PHP code example of sedlatschek / laravel-typescript-writer

1. Go to this page and download the library: Download sedlatschek/laravel-typescript-writer 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/ */

    

sedlatschek / laravel-typescript-writer example snippets


$simon = [
    'name' => 'Simon'
]

return [
    // The typescript file indentation
    'indentation' => 2,

    // The end-of-line character
    'eol_char' => PHP_EOL,

    // Whether to use single or double quotes for strings
    'single_quote' => true,

    // The files that should be written
    'files' => [
        /*
        new TypescriptFile(__DIR__.'/example.ts', [
            // The contents of the file
            new TypescriptData('Array<Test>', 'test', [
                [
                    'id' => 33,
                    'name' => 'test',
                    'active' => true,
                    'languages' => [
                        'German',
                        'English',
                    ],
                ],
            ]),
        ]),
        */
    ],
];

new TypescriptData(
    'Array<Test>',
    'test',
    // the data
    [
        [
            'test' => [
                'flags' => [
                    1,
                    2,
                    3,
                ],
            ],
        ],
    ],
    // the configured replacements
    [
        '*.test.flags' => [
            1 => 'SomeEnum.ABC',
            2 => 'SomeEnum.DEF',
            3 => 'SomeEnum.GHJ',
        ],
    ]),
sh
php artisan typescript-writer