tzsk / shorten-url
Google URL Shortener and Expander for Laravel.
Installs: 10 158
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 3
Open Issues: 2
Requires
- php: ^7.2
- illuminate/support: ~5.7|~5.8|~6.0
Requires (Dev)
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.0
README
Package for Shortening URL and Expanding URL with Google. This is a great combination if you plan to send Links in your Text Messages fired from your Application.
Install
Via Composer
$ composer require tzsk/shorten-url
Configure
First add the Service Provider and Facade in your app config file.
'providers' => [ ... Tzsk\ShortenUrl\Provider\ShortenUrlServiceProvider::class, ... ] ... 'aliases' => [ ... 'GoogleUrl' => Tzsk\ShortenUrl\Facade\GoogleUrl::class, ... ]
After that run vendor:publish
with flag config
:
$ php artisan vendor:publish --tag=config
Once you do that you will have a new file in your config folder.
config/url.php
There is only one criteria. Google API key for Shortening URL. Just login with google account and go to [https://console.developers.google.com]
Now create a new Application there. And Enable API
for URL Shortening.
And generate API Key
to use in Credentials
section.
Usage
# Use Class Path at the top of the File. use Tzsk\ShortenUrl\Facade\GoogleUrl; # Inside your Controller Method for Shortening. $short = GoogleUrl::shorten("LONG URL"); # Returns String. # OR... $short_data = GoogleUrl::extended()->shorten("LONG URL"); /** * For extended it will give the full response that google provides. */ # Inside your Controller Method for Expanding. $long = GoogleUrl::expand("SHORT URL"); # Returns String. # OR... $long_data = GoogleUrl::extended()->expand("SHORT URL"); /** * For extended it will give the full response that google provides. */
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email mailtokmahmed@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.