t URL by Ash Allen is a Laravel package for creating shortened URLs in your Laravel applications. You can easily create a new short URL with the following code to get started:
1use AshAllenDesign\ShortURL\Classes\Builder;2 3$builder = new Builder();4 5$shortURLObject = $builder->destinationUrl('https://destination.com')->make();6$shortURL = $shortURLObject->default_short_url;
It's up to you to configure and build short URLs around your existing data; for example, you could generate a short URL when a new post model is published.
This package provides all the basics and a bunch of advanced features to start creating short, sharable URLs for your apps. Its main features include:
- Custom URL Keys
- Single-use short URLs
- Enforce HTTPS
- Configure redirect status code (302 found instead of 301 permanent)
- Make a short URL active and inactive on a certain date
- Track Visitors:
- IP Address
- Browser Name
- Browser Version
- Operating System Name
- Operating System Version
- Referrer URL (the URL that the visitor originally came from)
- Device Type (can be: desktop/mobile/tablet/robot)
Here are more examples of working with existing ShortURL model instances from the README:
1use \AshAllenDesign\ShortURL\Models\ShortURL; 2 3// Find URL by key 4$shortURL = ShortURL::findByKey('abc123'); 5 6// Find by destination 7$shortURLs = ShortURL::findByDestinationURL('https://destination.com'); 8 9// Enable tracking to an existing short URL instance10$shortURL->trackingEnabled();11 12// Get model properties, such as visits13$shortURL = ShortURL::find(1);14$visits = $shortURL->visits;15 16// Single-use short URL17$builder = new \AshAllenDesign\ShortURL\Classes\Builder();18 19$shortURLObject = $builder20 ->destinationUrl('https://destination.com')21 ->singleUse()22 ->make();
Learn More
You can learn more about this package, get full installation instructions, and view the source code on GitHub. The README contains complete documentation with everything you need to set up and start interacting with short URLs.
0 comments:
Post a Comment
Thanks