

With MVC and URL manager, basic security is provided at a central level, and access to your application is fairly controlled. Without an MVC framework, any PHP file in your application can respond directly to requests, which means that you have to manage security across every file.

Url::to() calls UrlManager::createUrl() to create a URL Using createUrl() for this ensures that inbound requests can be successfully mapped.

Throughout your application, you'll need to generate URLs that can be properly parsed when requested by users. Requests are parsed into routes, which take this form: ControllerID/ActionIDĮssentially, URL Manager instructs Yii which controller and action method to create and invoke. Yii's URL manager is the application component that's used for parsing inbound requests, parseRequest(), as well as generating new URLs programmatically, createUrl(). Thank you for your patience and support-it's nice to be writing again regularly, and I'm looking forward to continuing coverage of Yii2.
#Yii2 nav widget direct url link series#
If you have a question or topic suggestion, please post a comment below or contact me on Twitter If you noticed the gap in between the Programming Yii series episodes, it's because I had to have brain surgery last year. Follow me as I review the basics.īefore we get started, please remember, I do try to participate in the discussions below. Yii provides a lot of flexibility in managing routing and generating links. The reverse process of linking to parts of your application is URL creation, which is best done programmatically. In today's tutorial, I'll review routing and URL creation in Yii. When a browser request arrives at your Yii application's index.php file, it must be parsed to determine which controller and method to call. In this Programming With Yii2 series, I'm guiding readers in use of the Yii2 Framework for PHP. If you're asking, "What's Yii?" check out Introduction to the Yii Framework, which reviews the benefits of Yii and includes an overview of Yii 2.0.
