1. Go to this page and download the library: Download mtymek/mini-url 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/ */
mtymek / mini-url example snippets
$pdo = new PDO("sqlite:links.db");
$service = new ShortUrlService('http://sho.rt', new PdoRepository($pdo));
$url = $service->shorten('http://github.com/zendframework/zend-diactoros');
echo $url->getShortUrl();
// example output: http://sho.rt/Wwr3bMu
interface RepositoryInterface
{
public function findByLongUrl($longUrl);
public function findByShortUrl($shortUrl);
public function save(ShortUrl $shortUrl);
}
$pdo = new PDO("sqlite:links.db");
$service = new ShortUrlService('http://mini.me', new PdoRepository($pdo));
$short = $service->shorten('http://google.com');
echo $short->getShortUrl();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.