service-to/base
最新稳定版本:1.1.1
Composer 安装命令:
composer require service-to/base
包简介
Library to convert integers to base62 strings, useful for shortURLs based on ID numbers in a database.
关键字:
README 文档
README
Library to convert integers to base62 strings, useful for shortURLs based on ID numbers in a database.
Usage
Install using composer...
composer require "service-to/base"
In a Laravel Controller
Route::get('{shortcode}', function ($shortcode) {
$base = new ServiceTo\Base();
return View::make("content")->withArticle(App\Article::find($base->base2int($shortcode)));
});
In plain old PHP
require_once("vendor/autoload.php");
use ServiceTo\Base;
function shorturl($url) {
$myshortdomain = "http://short.long.urls.3.14159.xyz/";
$base = new Base();
$stmt = $pdo->prepare("INSERT INTO shorturls SET url=?");
$stmt->bindValue(1, $url, PDO::PARAM_STR);
$stmt->execute();
return($myshortdomain . $base->int2base($stmt->lastInsertId()));
}
统计信息
- 总下载量: 158
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-30