Introduction
I recently tagged and released v6.0.0 and v6.1.0 of my Short URL package (ashallendesign/short-url).
In this Quickfire post, we're going to take a brief look at what's new and what's changed.
Customising the Short URL Prefix
Ryan Chandler made a contribution that added support for customising the prefix of the default short URL.
Previously, every short URL that was created used /short
as the prefix for the default_short_url
. For example, a typical short URL might have looked like this:
1https://example.com/short/ABC123
Now, you can change this prefix from short
to anything you'd prefer by changing the prefix
field in the short-url.php
config file. Using our previous example, if we updated the prefix in the config file to /s
, our URL would now look like this:
1https://example.com/s/ABC123
For more information, check out the original PR: #100
Forwarding Query parameters
Julien Arcin made a contribution that added support for forwarding query parameters sent in the request to the destination URL.
For example, let's say that you have the following short URL in your short_urls
table:
- default_short_url:
https://example.com/short/ABC123
- destination_url:
https://ashallendesign.co.uk/blog
Previously, if you were to go to https://example.com/short/ABC123?paramOne=hello
, you would be redirected to https://ashallendesign.co.uk/blog
.
However, by using the new query parameter forwarding feature, going to https://example.com/short/ABC123?paramOne=hello
would redirect you to https://ashallendesign/blog?paramOne=hello
. As you can see, the paramOne=hello
query parameter has been appended to the end of the destination URL.
To enable this feature, you can either set forward_query_params
to true
in the short-url.php
config file. Or, if you'd prefer to enable this feature on a case-by-case basis, you can use the forwardQueryParams()
method when building your short URLs like so:
1use AshAllenDesign\ShortURL\Facades\ShortURL;2 3ShortURL::destinationUrl('https://ashallendesign.co.uk/blog')4 ->forwardQueryParams()5 ->make();
For more information, check out the original PR: #94
Dropped older PHP and Laravel support
As part of the update to the v6.0.0 update, support for Laravel 6 and 7 was removed. Support for PHP 7.3 and 7.4 was also removed.
As a result of these changes, you must be using at least PHP 8.0 and Laravel 8 to use Short URL.
Conclusion
Hopefully, this post should have given you a brief overview of what's new in the Short URL package. You should also be able to see how we can customise the default short URL prefix and forward the user's query parameters.
If this post helped you out, I'd love to hear about it. Likewise, if you have any feedback to improve this post, I'd also love to hear that too.
If you're interested in getting updated each time I publish a new post, feel free to sign up for my newsletter below.
Keep on building awesome stuff! 🚀