PHP code example of bahirul / yii2-redirect

1. Go to this page and download the library: Download bahirul/yii2-redirect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bahirul / yii2-redirect example snippets


return [
    //...
    'components' => [
        //...
        'redirect' => [
            'class' => 'bahirul\yii2\Redirect',
        ],
    ],
];

return Yii::$app->redirect->to($url)->go(); //redirect only

return Yii::$app->redirect->to($url)->flash($flash_name, $flash_message)->go(); //redirect with flash message

return Yii::$app->redirect->prev()->go(); //redirect to previous page or home page (if previous page is null)

return Yii::$app->redirect->login()->go(); //redirect to login page