Short Url is a fantastic Laravel package that can be used for adding shortened URLs to your existing web app. Next, publish the package's config file and database migrations by the following command: php artisan vendor:publish --provider="AshAllenDesign\ShortURL\Providers\ShortURLProvider"

Example: $builder = new \AshAllenDesign\ShortURL\Classes\Builder(); $shortURLObject = $builder->destinationUrl('https://destination.com')->urlKey('custom-key')->make(); $shortURL = $shortURLObject->default_short_url; // Short URL: https://webapp.com/short/custom-key

If you want to override whether tracking is enabled or not when creating a shortened URL, you can use the ->trackVisits() method.

The example below shows how to enable IP address tracking for the URL and override the default config variable: $builder = new \AshAllenDesign\ShortURL\Classes\Builder(); $shortURLObject = $builder->destinationUrl('https://destination.com')->trackVisits()->trackIPAddress()->make(); Enforce HTTPS
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners