otifsolutions / shorturlapp
This is a laravel package to convert the url into short code and track the visits to the links.
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:laravel
This package is auto-updated.
Last update: 2025-03-14 20:33:50 UTC
README
PHP 8.1.2 > PHP 8
How to use the library
Install via the composer
Using the composer(Recommended)
Either run the following command in the root directory of your project:
composer require otifsolutions/shorturlapp
Then simply run migrations to run the ShortUrl and Tracker migrations
php artisan migrate
ShortUrl
Namespace for Model ShortUrl
use OTIFSolutions\ShortUrlApp\Models\ShortUrl;
-
Generate a new code against
Url
ShortUrl::set('Url');
Type of url is
STRING
-
Get a ShortUrl
ShortUrl::get('Url');
If Url does not exist the system will return null
-
Delete a
Url
ShortUrl::remove('Url');
If Url does not exist the system will return null.
Tracker
-
Namespace for Model
Tracker
,use OTIFSolutions\ShortUrlApp\Models\Tracker;
-
This model tracks the
url
and stores following details:ip_address
,full_url
,operating_system
andbrowser
.
Usage
- Url will be Tracked and redirected if the user sends
/url
request with generated code.abc.xyz/url?q=W2tht
.- Where 'url' is route, 'q' is a parameter and 'W2tht' is code which user generates.
- In the case of wrong parameter, following error will be returned.
return response()->json(['errors' => ['error' => 'url not exists']]);