arietimmerman / laravel-url-shortener
Laravel Package for shortening urls
Installs: 53 662
Dependents: 0
Suggesters: 0
Security: 0
Stars: 28
Watchers: 5
Forks: 13
Open Issues: 3
Requires
- php: ^7.0|^8.0
- illuminate/console: ^6.0|^7.0|^8.0|^9.0
- illuminate/database: ^6.0|^7.0|^8.0|^9.0
- illuminate/support: ^6.0|^7.0|^8.0|^9.0
- webpatser/laravel-uuid: ^3.0|^4.0
Requires (Dev)
- illuminate/testing: ^6.0|^7.0|^8.0
- orchestra/testbench: ^5.2 || ^6.0
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-10-13 13:38:14 UTC
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 5.5 and up (including 7.0 and up).
composer require arietimmerman/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
Usage for Laravel < 5.5
Add the service provider in your config/app.php
.
'providers' => [ /* [..] */ \ArieTimmerman\Laravel\URLShortener\ServiceProvider::class /* [..] */ ];
Optional
Publish the configuration and the view.
php artisan vendor:publish --provider="ArieTimmerman\Laravel\URLShortener\ServiceProvider"
Optionally, register for URLVisit events in your EventServiceProvider
.
protected $listen = [ 'ArieTimmerman\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