bahirul / yii2-redirect
Simple Yii2 Redirect Component
Installs: 57
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:extension
Requires
- yiisoft/yii2: ^2.0
This package is auto-updated.
Last update: 2021-01-19 03:59:36 UTC
README
Simple yii2 redirect component.
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require bahirul/yii2-redirect
or add
"bahirul/yii2-redirect": "^0.0.1"
to the require
section of your composer.json
file.
Configuring
Configure application components
as follows
return [ //... 'components' => [ //... 'redirect' => [ 'class' => 'bahirul\yii2\Redirect', ], ], ];
Usage
Use in your controller action
Redirect to URL
return Yii::$app->redirect->to($url)->go(); //redirect only
Redirect with flash message
return Yii::$app->redirect->to($url)->flash($flash_name, $flash_message)->go(); //redirect with flash message
Redirect to previous page
return Yii::$app->redirect->prev()->go(); //redirect to previous page or home page (if previous page is null)
Redirect to Login page
return Yii::$app->redirect->login()->go(); //redirect to login page