PHP development framework Yii1.1.8 is released. This version introduces more than 80 new features, enhancements, and bug fixes. You can write a custom URL rule class to process any complicated URL format and improved classautoloader for the application. Yii is a high-performance PHP 5 web application development framework. A simple command line tool yiic can be used to quickly
PHP development framework Yii 1.1.8 is released. This version introduces more than 80 new features, enhancements, and bug fixes. You can write a custom URL rule class to process any complicated URL format and improved class autoloader for the application. Yii is a high-performance PHP 5 web application development framework. A simple command line tool yiic can be used to quickly
PHP development framework Yii 1.1.8 is released. This version introduces more than 80 new features, enhancements, and bug fixes. You can write a custom URL rule class to process any complicated URL format and improved class autoloader for the application.
Yii is a high-performance PHP 5 web application development framework. Using a simple command line tool yiic, you can quickly create a web application code framework. developers can add business logic based on the generated code framework to quickly complete application development.
Use the url rule configuration of the custom URL rule class:
- array(
- // a standard rule mapping '/login' to 'site/login', and so on
- '
' => 'site/
',
-
- // a custom rule to handle '/Manufacturer/Model'
- array(
- 'class' => 'application.components.CarUrlRule',
- 'connectionID' => 'db',
- ),
-
- // a standard rule to handle 'post/update' and so on
- '
/
' => '
/
',
- ),
-
Custom url rule class extended fromCBaseUrlRule, Which can be implemented as follows:
- class CarUrlRule extends CBaseUrlRule
- {
- public $connectionID = 'db';
-
- public function createUrl($manager,$route,$params,$ampersand)
- {
- if ($route==='car/index')
- {
- if (isset($params['manufacturer'], $params['model']))
- return $params['manufacturer'] . '/' . $params['model'];
- else if (isset($params['manufacturer']))
- return $params['manufacturer'];
- }
- return false; // this rule does not apply
- }
-
- public function parseUrl($manager,$request,$pathInfo,$rawPathInfo)
- {
- if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches))
- {
- // check $matches[1] and $matches[3] to see
- // if they match a manufacturer and a model in the database
- // If so, set $_GET['manufacturer'] and/or $_GET['model']
- // and return 'car/index'
- }
- return false; // this rule does not apply
- }
- }
-
: Http://www.yiiframework.com/download/
Source: Open Source Chinese community