expirenza/shorturl-helper
Composer 安装命令:
composer require expirenza/shorturl-helper
包简介
Helper for generate short urls through EXPIRENZA API
README 文档
README
Helper for generate short url trough EXPIRENZA Short Url Service
Installation
- All the
coderequired to get started - For start to use this helper, you must have server API address and access token
Clone
- Clone this repo to your local machine using
https://github.com/EXPIRENZA/shorturl-helper
Composer
$ composer require expirenza/short-helper "^1.0.0"
How to use
Example #1
Convert a single url to getting single short url
<?php
use Expirenza\short\Link;
$class = new Link('some token', 'https://server.url');
$result = $class->getOne('https://google.com');
// output
var_dump($result);
Output:
string(35) "https://server.url/somerandomstring"
Example #2
Convert an url array to random urls arrays
<?php
use Expirenza\short\Link;
$class = new Link('some token', 'https://server.url');
$result = $class->getMany(['https://google.com', 'https://mail.com']);
// output
var_dump($result);
Output:
array(2) {
["https://google.com"] => string(32) "https://server.url/randomstring0"
["https://mail.com"] => string(32) "https://server.url/randomstring1"
}
Example #3
Convert an array of urls with early predefined codes
<?php
use Expirenza\short\Link;
$class = new Link('some token', 'https://server.url');
$source = [
0 => $class->getUniqueFormatItem('https://google.com', 'test_'.time().'_'.random_int(0, 99)),
1 => $class->getUniqueFormatItem('https://mail.com', 'test_'.time().'_'.random_int(0, 99)),
];
$result = $class->getUniqueMany($source);
// output
var_dump($result);
Output:
array(2) {
[0]=>
object(Expirenza\short\objects\UniqueResponse)#7 (3) {
["url":protected] => string(18) "https://google.com"
["code":protected] => string(18) "test_1595918241_18"
["success":protected] => bool(true)
}
[1]=>
object(Expirenza\short\objects\UniqueResponse)#8 (3) {
["url":protected] => string(16) "https://mail.com"
["code":protected]=> string(17) "test_1595918241_4"
["success":protected]=> bool(true)
}
}
In this case, access to protected property realised trough "get()" or "asArray()" methods:
<?php
foreach ($result as $item) {
echo $item->getUrl();
echo $item->getCode();
echo $item->getSuccess();
}
foreach ($result as &$item) {
$item = $item->asArray();
echo $item['url'];
echo $item['code'];
echo $item['success'];
}
Warning! If your predefined code is already used, you will get success property equal to false.
Support
Reach out to me at one of the following places!
expirenza/shorturl-helper 适用场景与选型建议
expirenza/shorturl-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 07 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 expirenza/shorturl-helper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 expirenza/shorturl-helper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-28