mauroziux / laravel-url-shortener
Laravel Package for shortening urls with Laravel 10 and 11 support
v2.0.0
2025-07-04 19:31 UTC
Requires
- php: ^8.1
- illuminate/console: ^9.0|^10.0|^11.0
- illuminate/database: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- webpatser/laravel-uuid: ^4.0
Requires (Dev)
- illuminate/testing: ^9.0|^10.0|^11.0
- orchestra/testbench: ^7.0|^8.0|^9.0
- phpunit/phpunit: ^9.0|^10.0
- squizlabs/php_codesniffer: ^3.5
README
A minimal Laravel package for shortening URLs. Apart for creating short URLs - like bitly - it also supported updating URL redirects and tracking URL clicks.
Laravel URL Shortener
Install the package. It supports Laravel 9.0, 10.0, and 11.0.
composer require mauroziux/laravel-url-shortener
php artisan migrate
And start shortening URLs
(string)URLShortener::shorten("http://www.example.com");
Or
php artisan url:shorten http://www.example.com
Requirements
- PHP 8.1 or higher
- Laravel 9.0, 10.0, or 11.0
Optional
Publish the configuration and the view.
php artisan vendor:publish --provider="Mauroziux\Laravel\URLShortener\ServiceProvider"
Optionally, register for URLVisit events in your EventServiceProvider
.
protected $listen = [ 'Mauroziux\Laravel\URLShortener\Events\URLVisit' => [ 'App\Listener\YourListener', ] ];
Configuration
See config/urlshortener.php
Docker
Build and start the docker container.
docker-compose build
docker-compose up
Now shorten an URL like this
docker-compose exec laravel-url-shortener php artisan url:shorten https://www.example.com
Check out the redirect
curl -v http://localhost:18123/code