U
U
UntitledNikname2019-10-28 20:52:00
Yii
UntitledNikname, 2019-10-28 20:52:00

Why is there no GET parameter in (yii2-advanced)?

I tried in every possible way to extract the get parameters from the URL. They simply don't exist ( url : "site.com/page?a=b" ).
The most common default controller created via gii with one method (index).

class TestController extends \yii\web\Controller
{
    public function actionIndex()
    {
        return $this->render('index');
    }
}

Yii::$app->request->get() => NULL,
$_GET => null
$_REQUEST => null

BUT in default SiteController it works and only there. Who knows why this might be?
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '' => 'site/index',
                '<action:(index|logout|signup|login)>' => 'site/<action>',
            ]
        ],

class SiteController extends Controller
{

    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::class,
                'rules' => [
                    [
                        'actions' => ['error', 'login'],
                        'allow' => true,
                    ],
                    [
                        'actions' => ['index', 'logout'],
                        'allow' => true,
                        'roles' => ['@'],
                        'matchCallback' => function () {
                            return !Yii::$app->user->isGuest;
                        },
                    ],
                    [
                        'actions' => ['signup'],
                        'allow' => true,
                        'roles' => ['?'],
                        'matchCallback' => function () {
                            return Yii::$app->user->isGuest;
                        },
                    ]
                ],
            ]
        ];
    }

    public function actionIndex()
    {
            ............
    }


    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
                'view' => '@app/views/site/error.php'
            ],
        ];
    }

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
UntitledNikname, 2019-10-29
@UntitledNikname

I noticed that without urlManager everything worked fine. I decided to get into the server settings. There was a problem with the correctness of the nginx settings.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question