fomvasss / laravel-punycode by fomvasss

Package for encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
17,790
4
3
Package Data
Maintainer Username: fomvasss
Maintainer Contact: fomvasss@gmail.com (Fomin Vasyl)
Package Create Date: 2017-06-15
Package Last Update: 2021-11-03
Language: PHP
License: MIT
Last Refreshed: 2024-11-15 15:01:47
Package Statistics
Total Downloads: 17,790
Monthly Downloads: 1,056
Daily Downloads: 54
Total Stars: 4
Total Watchers: 3
Total Forks: 4
Total Open Issues: 0

Laravel Punycode

This package converts a Unicode encoded domain name to a IDNA ASCII form and vice-versa.

Install

Run:

composer require "fomvasss/laravel-punycode"

For Laravel < 5.5 Add in ServiceProvider to the providers array in config/app.php

  Fomvasss\Punycode\PunycodeServiceProvider::class,

Copy the package config to your local config with the publish command (optional):

php artisan vendor:publish --provider="Fomvasss\Punycode\PunycodeServiceProvider" --tag="config"

Usage

Usage facade

You can now using the Facade (when added), using the PSR-3 levels (encode, decode): Add in your class the facade:

use Fomvasss\Punycode\Facades\Punycode;

Example usage:

var_dump(Punycode::encode('веб-вест.сайт'));
// outputs: xn----9sbccmd8fi.xn--80aswg;

var_dump(Punycode::decode('xn----9sbccmd8fi.xn--80aswg'));
// outputs: веб-вест.сайт

#Usage helper functions

punycode_encode('веб-вест.сайт');
punycode_decode('xn----9sbccmd8fi.xn--80aswg');

Links:

  • https://github.com/true/php-punycode

License

Faker is released under the MIT Licence. See the bundled LICENSE file for details.