Skip to content

laravel-ready/url-shortener

Repository files navigation

UrlShortener

UrlShortener

Stable Version Unstable Version Total Downloads License

📂 About

URL shortener for Laravel apps...

📦 Installation

Get via composer

composer require laravel-ready/url-shortener

⚙️ Configs

php artisan vendor:publish --tag=url-shortener-config

🏗️ Migrations

# publish migrations
php artisan vendor:publish --tag=url-shortener-migrations

# apply migrations
php artisan migrate --path=/database/migrations/laravel-ready/url-shortener

📝 Usage

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
);    

CreateShortUrlRequest

To see all validation rules, see the CreateShortUrlRequest class.

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
        );
    }
}

🔗 Postman

You can reach postman examples here.

⚓ Credits

  • This project was generated by the packager.