waavi / url-shortener
Laravel 5 的 URL 缩短器,支持 Google 和 Bitly 驱动。
1.0.8
2019-05-06 14:59 UTC
Requires
- illuminate/config: 5.1.x|5.2.x|5.3.*|5.4.*|5.5.*
- illuminate/support: 5.1.x|5.2.x|5.3.*|5.4.*|5.5.*
- mremi/url-shortener: ^2.0
Requires (Dev)
- mockery/mockery: ^0.9.4
- orchestra/testbench: 3.1.x|3.2.x|3.3.x|3.4.x|3.5.x
- phpunit/phpunit: ^6
README
简介
这是一个 URL 缩短器包,为 mremi/UrlShortener 提供方便的 Laravel Facade。
WAAVI 是一家位于西班牙马德里的网络开发工作室。您可以在 waavi.com 了解更多关于我们的信息。
Laravel 兼容性
安装和设置
通过 composer 安装
composer require waavi/url-shortener 1.0.x
或者手动编辑你的 composer.json 文件
"require": {
"waavi/url-shortener": "1.0.x"
}
在 config/app.php 中,将以下条目添加到 providers 数组的末尾
Waavi\UrlShortener\UrlShortenerServiceProvider::class,
并添加以下别名
'UrlShortener' => Waavi\UrlShortener\Facades\UrlShortener::class,
发布配置文件、表单视图和语言条目
php artisan vendor:publish --provider="Waavi\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');
```