search
Homephp教程php手册Yii 1.1.8发布,PHP开发框架

PHP开发框架Yii 1.1.8 发布。该版本引入了超过80个新功能、加强和bug修复。你可以编写自定义URL规则类来为应用程序处理任意复杂的URL格式,改进的class autoloader等。 Yii是一个高性能的PHP5的web应用程序开发框架。通过一个简单的命令行工具 yiic 可以快速

PHP开发框架Yii 1.1.8 发布。该版本引入了超过80个新功能、加强和bug修复。你可以编写自定义URL规则类来为应用程序处理任意复杂的URL格式,改进的class autoloader等。

Yii是一个高性能的PHP5的web应用程序开发框架。通过一个简单的命令行工具 yiic 可以快速创建一个web应用程序的代码框架,开发者可以在生成的代码框架基础上添加业务逻辑,以快速完成应用程序的开发。

使用自定义url规则类的URL 规则配置:

<ol>
<li><span><span>array(  </span></span></li>
<li><span>    // a standard rule mapping '/login' to 'site/login', and so on  </span></li>
<li>
<span>    '</span><span><span>action:</span><span>(login|logout|about)</span><span>></span><span>' =</span><span>></span><span> 'site/</span><span><span>action</span><span>></span><span>',  </span></span></span>
</li>
<li><span>   </span></li>
<li><span>    // a custom rule to handle '/Manufacturer/Model'  </span></li>
<li><span>    array(  </span></li>
<li>
<span>        'class' =</span><span>></span><span> 'application.components.CarUrlRule',  </span>
</li>
<li>
<span>        'connectionID' =</span><span>></span><span> 'db',  </span>
</li>
<li><span>    ),  </span></li>
<li><span>   </span></li>
<li><span>    // a standard rule to handle 'post/update' and so on  </span></li>
<li>
<span>    '</span><span><span>controller:</span><span>\w+</span><span>></span><span>/</span><span><span>action:</span><span>\w+</span><span>></span><span>' =</span><span>></span><span> '</span><span><span>controller</span><span>></span><span>/</span><span><span>action</span><span>></span><span>',  </span></span></span></span></span>
</li>
<li><span>),  </span></li>
<li><span> </span></li>
</ol>

自定义url规则类拓展自 CBaseUrlRule ,可以像如下方式实现:

<ol>
<li><span><span>class CarUrlRule extends CBaseUrlRule  </span></span></li>
<li><span>{  </span></li>
<li>
<span>    public $</span><span>connectionID</span><span> = </span><span>'db'</span><span>;  </span>
</li>
<li><span>   </span></li>
<li><span>    public function createUrl($manager,$route,$params,$ampersand)  </span></li>
<li><span>    {  </span></li>
<li>
<span>        if ($</span><span>route</span><span>==='car/index')  </span>
</li>
<li><span>        {  </span></li>
<li><span>            if (isset($params['manufacturer'], $params['model']))  </span></li>
<li><span>                return $params['manufacturer'] . '/' . $params['model'];  </span></li>
<li><span>            else if (isset($params['manufacturer']))  </span></li>
<li><span>                return $params['manufacturer'];  </span></li>
<li><span>        }  </span></li>
<li><span>        return false;  // this rule does not apply  </span></li>
<li><span>    }  </span></li>
<li><span>   </span></li>
<li><span>    public function parseUrl($manager,$request,$pathInfo,$rawPathInfo)  </span></li>
<li><span>    {  </span></li>
<li><span>        if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches))  </span></li>
<li><span>        {  </span></li>
<li><span>            // check $matches[1] and $matches[3] to see  </span></li>
<li><span>            // if they match a manufacturer and a model in the database  </span></li>
<li><span>            // If so, set $_GET['manufacturer'] and/or $_GET['model']  </span></li>
<li><span>            // and return 'car/index'  </span></li>
<li><span>        }  </span></li>
<li><span>        return false;  // this rule does not apply  </span></li>
<li><span>    }  </span></li>
<li><span>}  </span></li>
<li><span> </span></li>
</ol>

下载地址:http://www.yiiframework.com/download/

原文出自:开源中国社区

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.