leadthread / laravel-shortener
6.0.1
2017-04-20 01:02 UTC
Requires
- php: ^5.4|^7.0
- illuminate/support: ^5.0
- leadthread/php-bitly: ^4.0
- leadthread/php-google-shortener: ^2.0
Requires (Dev)
- orchestra/testbench: ^3.1
- phpunit/phpunit: ^4.8 || ^5.0
This package is auto-updated.
Last update: 2024-09-17 14:01:07 UTC
README
Laravel Shortener 是一个简单的包,通过各种在线服务缩短 URL。
当前支持
安装
通过 composer 安装 - 在终端中
composer require leadthread/laravel-shortener
现在将以下内容添加到 config/app.php
中的 providers
数组
LeadThread\Shortener\ShortenerServiceProvider::class
并将以下内容添加到 config/app.php
中的 aliases
数组
"Shortener" => "LeadThread\Shortener\Facades\Shortener",
然后您需要在终端中运行以下命令以复制配置文件
php artisan vendor:publish
用法
首先,您必须更改位于 config/shortener.php
的配置文件,使用您的 API 凭证。然后您可以简单地像这样缩短 URL
$url = "https://github.com/leadthread/laravel-shortener"; $shortUrl = Shortener::shorten($url); // (string) http://bit.ly/2amWdrE
Laravel Shortener 还利用了 Laravel 的缓存功能。只需简单编辑您的配置文件以更改缓存变量。
不要忘记将以下内容添加到文件顶部
//If you updated your aliases array in "config/app.php" use Shortener; //or if you didnt... use LeadThread\Shortener\Facades\Shortener;