adiafora / laravel-punycode
Laravel 5 中用于解码域名 punycode 的包
1.3
2019-07-23 19:15 UTC
Requires
- php: >=5.5.9
- illuminate/support: 5.4.*|5.5.*|5.6.*
This package is auto-updated.
Last update: 2024-09-12 04:46:19 UTC
README
此包可以将 Unicode 编码的域名转换为 IDNA ASCII 格式,反之亦然。
此包基于另一个包 - fomvasss/laravel-punycode。但将 idna_convert 类作为主要类。它允许您使用任何书写方式的域名:仅域名、带 www 的域名、协议、脚本、参数等。
如果您不小心将英文字符域名编码为 punycode,则它不会发生任何问题,没有错误和意外结果。您可以在所有域名上安全地使用此包,它会为您做所有事情。
安装
运行
composer require "adiafora/laravel-punycode"
对于 Laravel < 5.5,将 ServiceProvider 添加到 config/app.php 中的 providers 数组中
Adiafora\Punycode\PunycodeServiceProvider::class,
用法
用法门面
您现在可以使用门面默认使用。
对于 Laravel < 5.5,将 Facade 添加到 config/app.php 中的 aliases 数组中
'Punycode' => Adiafora\Punycode\Facades\Punycode::class,
示例用法
var_dump(Punycode::encode('мой-веб-сайт.сайт')); // outputs: xn-----8kcceszgtu3bo.xn--80aswg var_dump(Punycode::decode('xn-----8kcceszgtu3bo.xn--80aswg')); // outputs: мой-веб-сайт.сайт
用法辅助函数
punycode_encode('мой-веб-сайт.сайт'); punycode_decode('xn-----8kcceszgtu3bo.xn--80aswg');
许可证
MIT 许可证 (MIT)。请参阅许可证文件以获取更多信息。