PHP code example of zvermafia / transliteration-laravel

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

    

zvermafia / transliteration-laravel example snippets

 php


namespace App\Http\Controllers;

// use LaraTransliterator; // but we won't use the facade in this example
use Zvermafia\Transliteration\Interfaces\TransliteratorInterface;

class PoorWorkerController
{
    public function translit(Request $request, TransliteratorInterface $transliterator)
    {
        $result = $transliterator->setText($request->input('text'))
            ->toCyrillic()
            ->translit()
            ->getResult();

        return response()->json(compact('result'));
    }
}
 php
// in your routes file
Route::post('translit', '\Zvermafia\TransliterationLaravel\Controllers\TransliteratorController');