2015-01-15 12 views

risposta

6

Si dovrebbe usare semplicemente un percorso:

Url::to(['my_controller/action']); 

E se si vuole un URL di base assoluto:

Url::to(['my_controller/action'], true); 

Per saperne di più:

http://www.yiiframework.com/doc-2.0/yii-helpers-baseurl.html#to()-detail

http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#creating-urls

+0

No, lo so, ma restituisce solo my_controller/action –

+5

Finalmente ho capito, dobbiamo solo passare true dopo l'url ad esempio: 'Url: to (['my_controller/action'], true)' restituirà http : //example.com/my_controller/action. –

2

Segui urlManager E Richiesta In Yiiframework 2.0 con l'esempio


  • Yii :: $ app-> basePath **** >>>> **** D: \ wamp \ www \ yiiframework2 0,0 \ progetto \ backend

  • Yii :: $ app-> homeUrl; **** >>>> **** /yiiframework2.0/project/backend/web/index.php

  • Yii :: $ app-> getUrlManager() -> createUrl ('user') **** **** >>>> /yiiframework2.0/project/backend/web/index.php?r=user

  • Yii :: $ app-> urlManager-> createUrl (['site/page', 'id' => 'about']) **** >>>> ****
    /yiiframe work2.0/progetto/backend/web/index.php? r = sito% 2Fpage & id = circa

  • Yii :: $ app-> urlManager-> createUrl ([sito '/ visualizza ',' id '=> 105]) **** >>>> **** /yiiframework2.0/project/backend/web/index.php?r = sito% 2Fview & id = 105



  • Yii :: $ app-> request-> baseurl **** >>>> **** /yiiframework2.0/project/backend/web


  • Yii :: $ app-> request-> url **** >>>> ****
    /yiiframework2.0/project/backend/web/index.php