1. Go to this page and download the library: Download serbanblebea/urlshortener 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/ */
namespace App\Http\Controllers;
use SerbanBlebea\UrlShortener\ShortUrl;
class TestController extends Controller
{
public function index()
{
$url = ShortUrl::shortenUrl('name-of-the-url', 'http://url-that-you-want-to-shorten.com');
$short_url = $url->getShortUrl()
// return http://www.name-of-your-host.com/s/fs53rw7h
// 's' => name of the 'special_route_param' in config file
}
}
namespace App\Http\Controllers;
use ShortUrl;
class TestController extends Controller
{
public function index()
{
// old_id = 'eujfg849'
// new_id = 'soda'
// Use this method to change the unique id
ShortUrl::changeUniqueId('eujfg849', 'soda');
}
}
namespace App\Http\Controllers;
use ShortUrl;
class TestController extends Controller
{
public function index()
{
// Get the short url from database by url name
ShortUrl::count('name-of-url');
}
}
namespace App\Http\Controllers;
use ShortUrl;
class TestController extends Controller
{
public function index()
{
$url = ShortUrl::shortenUrl('name-of-the-url', 'http://url-that-you-want-to-shorten.com', 'campaign-name', 'medium-name', 'source-name');
}
}
namespace App\Http\Controllers;
use ShortUrl;
class TestController extends Controller
{
public function index()
{
$url = ShortUrl::shortenUrl('name-of-the-url', 'http://url-that-you-want-to-shorten.com');
$url->update([
'campaign' => 'campaign-name',
'medium' => 'medium-name',
'source' => 'source-name'
]);
}
}
namespace App\Http\Controllers;
use ShortUrl;
class TestController extends Controller
{
public function resetCount()
{
$count = ShortUrl::get('name-of-the-short-url')->resetCounter();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.