kostasch / greeklish
Convert Greek text to greeklish (latin) and generate URL friendly slugs for Laravel.
Requires
- php: ^8.3
- illuminate/support: ^12.0 || ^13.0
Requires (Dev)
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0 || ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
README
Convert Greek text to latin characters and generate clean, URL-friendly slugs for Laravel.
Vowels follow the ELOT 743 / ISO 843 letter-preserving rules (αι→ai, ει→ei, οι→oi, υι→yi, υ→y), with the αυ/ευ/ηυ voicing rules (αυτός → aftos, ευρώ → evro), accent and diaeresis stripping, and guillemet removal. Greek names transcribe as on a passport — Αικατερίνη → aikaterini, Ειρήνη → eirini, Οικονόμου → oikonomou.
Requirements
- PHP 8.3+
- Laravel 12 or 13
Installation
composer require kostasch/greeklish
The service provider and the Greeklish facade are registered automatically through Laravel package discovery — no configuration required.
Usage
use Kostasch\Greeklish\Facades\Greeklish; Greeklish::make('Γεια σου Κόσμε'); // "geia sou kosme" Greeklish::text('Γεια σου Κόσμε'); // "geia sou kosme" Greeklish::slug('Γεια σου Κόσμε'); // "geia-sou-kosme"
make()
Raw transliteration of Greek to latin, leaving spacing and punctuation in place.
Greeklish::make('Καλημέρα!'); // "kalimera!"
text()
Transliteration with optional stripping of short words.
Greeklish::text('ο σκύλος μου'); // "o skylos mou" Greeklish::text('ο σκύλος μου', true); // "skylos mou" (drops one-letter words) Greeklish::text('το σπίτι', false, true); // "spiti" (drops two-letter words)
slug()
Builds a URL-friendly slug. stopOne defaults to true, so one-letter words are dropped.
Greeklish::slug('Άρθρο για την Ελλάδα'); // "arthro-gia-tin-ellada" Greeklish::slug('ο σκύλος μου'); // "skylos-mou" Greeklish::slug('ο σκύλος μου', false); // "o-skylos-mou"
Without the facade
The class is bound in the container and can be resolved or injected directly:
use Kostasch\Greeklish\Greeklish; public function store(Greeklish $greeklish): void { $slug = $greeklish->slug($request->title); }
Testing
composer test
License
The MIT License (MIT). Please see LICENSE.md for more information.