phpsa / laravel-yourls-plugin
Plugin which integrates Laravel with Yourls (Your Own URL Shortener).
Fund package maintenance!
phpsa
Installs: 2 787
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 3
Forks: 6
Open Issues: 1
Requires
- php: ^7.1|^8.0|^8.1
- guzzlehttp/guzzle: ~6.0|^7.0
- illuminate/support: ~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^4.0|^5.0|^6.0|^7.0
- phpunit/phpunit: ^8.0|^9.0|^10.0
This package is auto-updated.
Last update: 2024-12-13 04:49:11 UTC
README
Package description: Plugin which integrates Laravel with Yourls (Your Own URL Shortener).
Installation
Install via composer
composer require phpsa/laravel-yourls-plugin
Register Service Provider
Note! This and next step are optional if you use laravel>=5.5 with package auto discovery feature.
Add service provider to config/app.php
in providers
section
Phpsa\LaravelYourlsPlugin\ServiceProvider::class,
Register Facade
Register package facade in config/app.php
in aliases
section
'ShortUrl' => Phpsa\LaravelYourlsPlugin\Facades\LaravelYourlsPlugin::class,
Publish Configuration File (optional)
php artisan vendor:publish --provider="Phpsa\LaravelYourlsPlugin\ServiceProvider" --tag="config"
Configuration Settings
you can set the following values in your environment file
LARAVEL_YOURLS_PLUGIN_URL= LARAVEL_YOURLS_PLUGIN_USERNAME= LARAVEL_YOURLS_PLUGIN_PASSWORD= LARAVEL_YOURLS_PLUGIN_SIGNATURE= LARAVEL_YOURLS_PLUGIN_FORMAT=json
Authentication can use either the username / password combo or the signature
Usage
using the Facade: you can access the following methods:
shorturl
Generates a short url for your long url
\ShortUrl::shorturl(string $url [, string $title = NULL [], string $keyword = NULL [], string $format = NULL ]]] )
Parameters
- $url - required - the url you wish to create a short url for
- $title - optional - Title of the short url
- $keyword - optional - Title for the short url (ie short.url/{keyword})
- $format - optional - Change the format for this specific request (json / xml)
Returns string - the short url that was generated
expand
Expands inforation about your short url
\ShortUrl::expand(string $shorturl [, string $format = null] )
Parameters
- $shorturl - required - the shorturl to expand (can be either 'abc' or 'http://site/abc')
- $format - optional - Change the format for this specific request (json / xml)
Returns stdClass - object of the response details
urlStats
Get stats about one short URL
\ShortUrl::expand(string $shorturl [, string $format = null] )
Parameters
- $shorturl - required - the shorturl to expand (can be either 'abc' or 'http://site/abc')
- $format - optional - Change the format for this specific request (json / xml)
Returns stdClass - object of the response details
stats
Get stats about one short URL
\ShortUrl::stats( [string $filter = null [, int $limit = null [, string $format = null ]]] )
Parameters
- $filter - optional - the filter: either "top", "bottom" , "rand" or "last"
- $limit - optional - the limit (maximum number of links to return)
- $format - optional - Change the format for this specific request (json / xml)
Returns stdClass - object of the response details
dbStats
Get stats about one short URL
\ShortUrl::dbStats([ string $format = null] )
Parameters
- $format - optional - Change the format for this specific request (json / xml)
Returns stdClass - object of the response details
getLastResponse
Gets the full response body from the last request
\ShortUrl::getLastResponse()
Parameters N/A
Returns stdClass|string response of the last request body
Security
If you discover any security related issues, please email instead of using the issue tracker.