abstractrs / url-shortener
支持Google和Bitly驱动的Laravel 5 URL缩短器。
2.0.1
2019-05-16 08:33 UTC
Requires
- illuminate/config: 5.6.*|5.7.*|5.8.*
- illuminate/support: 5.6.*|5.7.*|5.8.*
- mremi/url-shortener: 2.2.x
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: 3.6.x|3.7.x|3.8.x
- phpunit/phpunit: ^7.0|^8.0
README
简介
这是一个提供便捷Laravel Facade的URL缩短器包,兼容mremi/UrlShortener
Laravel 兼容性
安装和配置
通过composer安装
composer require abstractrs/url-shortener
或者手动编辑你的composer.json文件
"require": {
abstractrs/url-shortener": "^2.0"
}
在config/app.php中,将以下条目添加到提供者数组的末尾
Abstractrs\UrlShortener\UrlShortenerServiceProvider::class,
并添加以下别名
'UrlShortener' => Abstractrs\UrlShortener\Facades\UrlShortener::class,
发布配置文件、表单视图和语言条目
php artisan vendor:publish --provider="Abstractrs\UrlShortener\UrlShortenerServiceProvider"
检查配置文件,设置所选驱动器所需的环境变量。
使用方法
缩短一个URL
```php
\UrlShortener::shorten('http://google.com'); // Uses default driver as per config settings
\UrlShortener::driver('bitly')->shorten('http://google.com');
```
扩展一个URL
```php
\UrlShortener::expand('http://google.com'); // Uses default driver as per config settings
\UrlShortener::driver('bitly')->expand('http://google.com');
```