Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eseperio/yii2-url-shortener
Url shortener for Yii2
https://github.com/eseperio/yii2-url-shortener
Last synced: 2 months ago
JSON representation
Url shortener for Yii2
- Host: GitHub
- URL: https://github.com/eseperio/yii2-url-shortener
- Owner: Eseperio
- License: gpl-3.0
- Created: 2019-07-03T10:26:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-11T21:14:11.000Z (over 1 year ago)
- Last Synced: 2024-10-20T23:12:38.518Z (3 months ago)
- Language: PHP
- Size: 28.3 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Yii2 url shortener.
Do not get fooled by the age of changes made to library. It works like the first day, and that is why it has not been updated
Make short links within your own yii2 application. Can even define an expiration date for a shortened url. See this readme file to learn how.
## Installation
Add the module to your config file:
**First:** Run the migration included in @vendor/eseperio/yii2-url-shortener/src/migrations.
```php
//...'modules' => [
'shortener' => [
'class' => \eseperio\shortener\ShortenerModule::class
]
]//...
```
Add the bootstrap class to your bootstrap configuration.
```php'basePath' => dirname(__DIR__),
'bootstrap' => [
'log',
\eseperio\shortener\Bootstrap::class,
],'aliases' => [
//...
```## Usage
Making a short link
```php
Yii::$app->getModule('shortener')->short('http://original.url/goes/here')// An array can be provided too.
Yii::$app->getModule('shortener')->short(['controller/action','param' => 'value'])
```A lifetime can be established. Link will stop working since that date.
```php
Yii::$app->getModule('shortener')->short($url, 3600)
```Expanding a link
```php
Yii::$app->getModule('shortener')->expand('link id')
```## Redirection
Module includes a controller to handle redirections. The only thing you need, to make it work, it is create a link to your app domain, followed by the short id of url.`http://myapp.tld/gGyU`