artoodetoo/urly
Composer 安装命令:
composer require artoodetoo/urly
包简介
Minimum viable URL shortener class
关键字:
README 文档
README
Do you want to encode URLs like tinyurl.com does?
This is helper tool for you.
Features
Urly uses PDO interface to store URLs. Just refer to your existing connection.
Optionally you can specify table name, key encode base and XOR mask.
Access methods are quite obvious: set($url) and get($key).
Install
To install with composer:
composer require artoodetoo/urly
Required table structure:
CREATE TABLE `urly` ( `id` int(10) NOT NULL AUTO_INCREMENT, `url` varchar(1000) NOT NULL, PRIMARY KEY (`id`) )
Basic Usage
Save URL and het encoded key:
$db = new \PDO( 'mysql:dbname=homestead;host=127.0.0.1;charset=utf8', 'homestead', 'secret' ); // Set 62 base to get alfa-numeric key in both cases and // some magic number to make key sequence be less predictable $shortener = new \R2\Utility\Urly($db, 'my_urly', 62, 990749); $key = $shortener->set('http://localhost/test.txt'); echo 'http://go.to/'.$key."\n"; // Something like 'http://go.to/49Jz'
Get URL by key:
echo $shortener->get('49Jz'); // Saved URL or empty string if not found
License
The Urly is open-source software, licensed under the MIT license
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-28