PHP code example of artoodetoo / urly
1. Go to this page and download the library: Download artoodetoo/urly library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
artoodetoo / urly example snippets
$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'
echo $shortener->get('49Jz'); // Saved URL or empty string if not found