N
N
nepster-web2014-03-11 12:50:18
Yii
nepster-web, 2014-03-11 12:50:18

How to properly use urlManager in yii2?

There were 2 questions:
1) Generation of url addresses

\Yii::$app->urlManager->createUrl(['/users/all/','page'=>2]);

'enablePrettyUrl' => true, set
'enablePrettyUrl' => true, set
How can I generate the address: /users/all/page/2 ?
2) How to write a rule for urlManager correctly?
For example, I write like this:
'users/all' => 'users/default/all',
In this case:
users / all - works
users / all / - does not work
How to make both of these options work?
This is a test example, in practice:
There is a users module, it has a default controller.
the address looks like this: /users/default/action
How in yii2 you can make a rule that all actions from the default controller are available like this:
/users/action1
/users/action1/
/users/action2
/users/action2/
...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Morozov, 2014-03-11
@nepster-web

In v2, the structure of generating a list of parameters has really changed, in order to return to the old form, you need to write your own rules, something like
I guess you can still connect your own class-based rule so as not to mess around every time.

P
phpnt, 2015-04-20
@phpnt

Recently made a video on UrlManager

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question