Yii1.1.8 released, PHP development framework

Source: Internet
Author: User
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:

 
  1. array(
  2. // a standard rule mapping '/login' to 'site/login', and so on
  3. ' ' => 'site/ ',
  4. // a custom rule to handle '/Manufacturer/Model'
  5. array(
  6. 'class' => 'application.components.CarUrlRule',
  7. 'connectionID' => 'db',
  8. ),
  9. // a standard rule to handle 'post/update' and so on
  10. ' / ' => ' / ',
  11. ),

Custom url rule class extended fromCBaseUrlRule, Which can be implemented as follows:

 
  1. class CarUrlRule extends CBaseUrlRule
  2. {
  3. public $connectionID = 'db';
  4. public function createUrl($manager,$route,$params,$ampersand)
  5. {
  6. if ($route==='car/index')
  7. {
  8. if (isset($params['manufacturer'], $params['model']))
  9. return $params['manufacturer'] . '/' . $params['model'];
  10. else if (isset($params['manufacturer']))
  11. return $params['manufacturer'];
  12. }
  13. return false; // this rule does not apply
  14. }
  15. public function parseUrl($manager,$request,$pathInfo,$rawPathInfo)
  16. {
  17. if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches))
  18. {
  19. // check $matches[1] and $matches[3] to see
  20. // if they match a manufacturer and a model in the database
  21. // If so, set $_GET['manufacturer'] and/or $_GET['model']
  22. // and return 'car/index'
  23. }
  24. return false; // this rule does not apply
  25. }
  26. }

: Http://www.yiiframework.com/download/

Source: Open Source Chinese community

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.