PHP code example of laravel-ready / url-shortener

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

    

laravel-ready / url-shortener example snippets


use LaravelReady\UrlShortener\Enums\ShortingType;
use LaravelReady\UrlShortener\Supports\UrlShortener;

$shortUrl = UrlShortener::shortUrl(
    'https://github.com/laravel-ready/url-shortener',
    [
        'title' => 'TEST TITLE',
        'description' => 'Lorem ipsum dolar amet',
    ],
    ShortingType::Emoji
);    

use LaravelReady\UrlShortener\Requests\CreateShortUrlRequest;

class ShortUrlController extends Controller
{
    public function store(CreateShortUrlRequest $request)
    {
        $validateData = $request->validated();

        $shortUrl = UrlShortener::shortUrl(
            $validateData['url'],
            $validateData['meta'] ?? [],
            $validateData['type'] ?? ShortingType::Random
        );
    }
}
bash
php artisan vendor:publish --tag=url-shortener-config