search
Homephp教程php手册Yii配置文件用法详解

这篇文章主要介绍了Yii配置文件用法,以实例形式较为详细的分析了项目开发中的控制器、项目名、pathinfo、日志等的配置技巧,非常具有实用价值,需要的朋友可以参考

本文详细分析了Yii配置文件的用法。分享给大家供大家参考。具体分析如下:

Yii配置文件比ThinkPHP复杂多了,先把自己了解的配置记录下来,,感兴趣的朋友可以参考一下:

复制代码 代码如下:

// 主配置文件
$config = array(
    'modules' => array(
        'gii' => array(
            'class' => 'system.gii.GiiModule',
            'password' => 'admin',
        ),
    ),
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
    'name' => 'Yii学习', //项目名称
    'preload' => array('log'),
    'import' => array(//自动加载类
        'application.models.*',
        'application.components.*',
    ),
    'defaultController' => 'index', //默认控制器
    'layout' => 'layout', //layout文件
    'components' => array(
        'db' => array(//数据库配置
            'connectionString' => 'mysql:host=localhost;dbname=h.me',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'tablePrefix' => 'tp_',
            'enableParamLogging' => true, //显示带参数的SQL
        ),
        'urlManager' => array(
            'urlFormat' => 'path', //pathinfo模式
            'showScriptName' => false, //隐藏index.php时需要设置false
        //  'urlSuffix' => '.html', //url后缀相当于伪静态
        ),
        'errorHandler' => array(
            'errorAction' => 'index/error', //404错误跳转到所在方法
        ),
        'log' => array(//日志
            'class' => 'CLogRouter',
            'routes' => array(
                array(
                    'class' => 'CWebLogRoute',
                    'levels' => 'trace,error,waring', //Application Log 显示级别
                    'categories' => 'system.*', //记录类别
                ),
            ),
        ),
    ),
    'params' => require(dirname(__FILE__) . '/params.php'),
);
 
return $config;
?>

希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!