2017 © Pedro Peláez
 

library urly

Minimum viable URL shortener class

image

artoodetoo/urly

Minimum viable URL shortener class

  • Wednesday, December 28, 2016
  • by artoodetoo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 20 % Grown

The README.md

Urly - Minimum viable URL shortener

Do you want to encode URLs like tinyurl.com does?
This is helper tool for you., (*1)

Features

Urly uses PDO interface to store URLs. Just refer to your existing connection., (*2)

Optionally you can specify table name, key encode base and XOR mask., (*3)

Access methods are quite obvious: set($url) and get($key)., (*4)

Install

To install with composer:, (*5)

composer require artoodetoo/urly

Required table structure:, (*6)

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:, (*7)

$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:, (*8)

echo $shortener->get('49Jz'); // Saved URL or empty string if not found

License

The Urly is open-source software, licensed under the MIT license, (*9)

The Versions

28/12 2016

dev-master

9999999-dev

Minimum viable URL shortener class

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Avatar artoodetoo

url shortener

28/12 2016

v0.1.0

0.1.0.0

Minimum viable URL shortener class

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Avatar artoodetoo

url shortener