Download the PHP package eru/avro-phonetic without Composer
On this page you can find all versions of the php package eru/avro-phonetic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package avro-phonetic
Avro Phonetic
A high-performance Avro Phonetic transliteration library for PHP. Convert Banglish (Romanized Bengali) to Bengali script with blazing-fast Trie-based pattern matching and context-sensitive rule engine.
โจ Features
- ๐ Trie-Based Pattern Matching โ O(m) lookup time instead of O(nรm) linear search
- ๐ฏ Context-Sensitive Rules โ Intelligent conversion based on surrounding characters
- ๐ Laravel Ready โ Auto-discovery, Facade, and config publishing out of the box
- ๐ฆ Standalone Compatible โ Works with any PHP project, no framework required
- ๐งช Fully Tested โ 180+ tests covering all functionality
- โก Memory Efficient โ Singleton pattern with lazy-loaded grammar
- ๐ง PHP 5.6+ โ Compatible with PHP 5.6 through 8.x
๐ฏ What Makes This Unique?
Trie Data Structure for Fast Lookups
Unlike traditional implementations that linearly scan through hundreds of patterns, we use a Trie (prefix tree) data structure. This provides:
- O(m) lookup time where m is the pattern length (vs O(nรm) for linear search)
- Efficient longest-match finding โ automatically finds the longest matching pattern
- Minimal memory overhead โ shared prefixes are stored only once
Context-Sensitive Rule Engine
Our rule engine understands context! The same input can produce different outputs based on what comes before or after:
Supported rule scopes:
vowel/!vowelโ Check if prefix/suffix is a vowelconsonant/!consonantโ Check if prefix/suffix is a consonantpunctuation/!punctuationโ Check for word boundariesexact/!exactโ Match specific characters
๐ฆ Installation
๐ Quick Start
Basic Usage
Helper Functions
Laravel Usage
The package auto-registers with Laravel 5.5+. No additional setup required!
Using the Facade:
In Blade templates:
Publish configuration (optional):
This creates config/avro-phonetic.php where you can customize the grammar file path.
๐ API Reference
Avro Class
Helper Functions
โ๏ธ Advanced Usage
Custom Grammar
You can provide your own grammar rules:
Load Grammar from File
Direct Parser Access
For performance-critical applications, access the parser directly:
๐๏ธ Performance
Benchmarks on typical hardware (PHP 8.x):
| Operation | Time |
|---|---|
| Single word conversion | ~0.05ms |
| Sentence (10 words) | ~0.1ms |
| Paragraph (100 words) | ~0.8ms |
| Trie initialization | ~15ms (one-time) |
The Trie is built once and reused via singleton pattern, making subsequent conversions extremely fast.
๐งช Testing
๐ Project Structure
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Write tests for your changes
- Ensure all tests pass (
composer test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This package is open-sourced software licensed under the GPL-3.0 License.
๐ Credits
- Based on the Avro Phonetic keyboard layout
- Rule engine ported from pyAvroPhonetic by Kaustav Das Modak
- Developed by Erfan Ahmed Siam
Made with โค๏ธ for the Bengali language
All versions of avro-phonetic with dependencies
ext-json Version *
ext-mbstring Version *