PHP code example of hatchetaustralia / laravel-url-shortener

1. Go to this page and download the library: Download hatchetaustralia/laravel-url-shortener 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/ */

    

hatchetaustralia / laravel-url-shortener example snippets


'providers' => [
   ...
   Hatchet\UrlShortener\UrlShortenerServiceProvider::class,
   ...
],

$shortener = app('url.shortener');
// or...
$shortener = url()->shortener();

// This will return your shortened URL as a string
$shortener->shorten(...);

// This will return a promise which will resolve to your shortened URL
$shortener->shortenAsync(...);

// You can also call shortening from Laravel's url component directly
url()->shorten(...);

// or...
app('url')->shorten(...);

// or even...
app('url.shortener')->shorten(...);

class MyController extends Controller
{
    public function myFunction(ShortenerManager $shortener)
    {
        $shortener->shorten(...);
    }
}

public function boot(ShortenerManager $shorteners)
{
    $shorteners->extend('my_driver', function ($app, $config) {
       // Return your driver instance here
    });
}