orlovtech/short-link
Composer 安装命令:
composer require orlovtech/short-link
包简介
Link shortener package for Laravel
README 文档
README
Table of Contents
Overview
A Laravel package that can be used for adding shortened URLs to your existing web app.
Installation
Requirements
The package has been developed and tested to work with the following minimum requirements:
- PHP >=8.1
- Laravel >=9.0
Install the Package
You can install the package via Composer:
composer require orlovtech/short-link
Publish the Config and Migrations
You can then publish the package's config file and database migrations by using the following command:
php artisan vendor:publish --provider="OrlovTech\ShortLink\Providers\ShortLinkServiceProvider"
at this config file you can change the prefix you want to use. By default it's a /short/.
Migrate the Database
This package contains one migration that add a new table to the database: short_links. To run this migration, simply run the following command:
php artisan migrate
Generate the Link
The fastest way to generate new link is to use the facade OrlovTech\ShortLink\Facades\ShortLink like this:
ShortLink::generate('https://yourlink.com');
This method will return you short version of your link.
Method generate also has the second parameter singleUse as an option.
With this parameter you can specify that your link should be deleted after it was used for the first time.
So the full view might be:
ShortLink::generate( 'https://yourlink.com', singleUse: true, );
To show ready link use param default_short_url like so:
$link = ShortLink::generate('https://yourlink.com'); echo config('app.url') . $link->default_short_url;
Use the link
When you have ready link you can use the endpoint https://yourdomain.com/short/628ac418-865a
where short is the prefix from config file
Testing
To run the package's unit tests, run the following command:
vendor/bin/phpunit
License
The MIT License (MIT). Please see License File for more information.
orlovtech/short-link 适用场景与选型建议
orlovtech/short-link 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 771 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 orlovtech/short-link 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 orlovtech/short-link 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 771
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-24