- 浏览: 400394 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
goahead2010:
有用
JS遍历对象或者数组 -
bishibaodian:
不要在这样找笔试题了,一次就这么几个,还没过瘾就没有了,去安装 ...
整理了一份招PHP高级工程师的面试题 -
smallearth:
不错
整理了一份招PHP高级工程师的面试题 -
ipodao:
暂时没发现啊!
IE域名带有下划线导致的session丢失 -
ipodao:
谢了
JS遍历对象或者数组
YII配置
- 博客分类:
- Yii
用YIIFramework的库开发
Yii::import(class1,true),在将class1类文件路径存储时,同时include该文件
注意:你也可以将配置文件分为多个文件, // 例如: db.php, params.php等等 。Yii::import('db',true); main.php
- <?php
- // 取消下行的注释,来定义一个路径别名
- // Yii::setPathOfAlias('local','path/to/local-folder');
- // 这是 Web 应用配置的主体部分。任何可写的
- // CWebApplication 属性可以在这里配置。
- return array(
- // protected 目录的基础路径
- // 使用 Yii::app()->basePath 来访问
- 'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
- // 应用的名字
- // 使用 Yii::app()->name 来访问
- 'name'=>'My website',
- //路径别名
- // 可以是应用内部的路径,也可以是外部资源
- 'aliases'=>array(
- 'myExternalFramework'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'myexternalframework'
- ),
- //维护程序时,这样子所有的请求转发到一个地方
- 'catchAllRequest'=>array('site/all'),
- //如何在应用程序处理请求之前执行一段操作?当然这个function方法要存在index.php
- 'onBeginRequest' => 'function',
- //building on above for a controller in the external
- //framework you can use the controller map to map the
- //controller path
- 'controllerMap'=>array('myController'=>'myExternalFramework.controllers.MyController'),
- // 默认的 controller
- 'defaultController'=>'site',
- // 用户语言(for Locale)
- 'language'=>'es',
- //信息和视图的语言
- 'sourceLanguage'=>'es',
- 'timeZone'=>'Asia/Shanghai',
- 'theme'=>'school',
- // 使用的字符集
- 'charset'=>'utf-8',
- // 预载入的应用组件
- 'preload'=>array('log'),
- // 自动载入的类
- 'import'=>array(
- 'application.models.*',
- 'application.components.*',
- ),
- // 可以使用 Yii::app()->params['paramName'] 访问的应用级别的参数
- 'params'=>array(
- 'adminEmail'=>'info@example.com',
- ),
- // 注意:你也可以将配置文件分为多个文件,
- // 例如: db.php, params.php 等等。
- // 你可以这样做:
- // 'params'=>require(dirname(__FILE__).'/params.php'),
- // 在 params.php 中你需要返回这个数组:
- // return array('adminEmail'=>'info@example.com');
- // 应用组件的配置
- 'components'=>array(
- // assets, 参考www.yiiframework.com/doc/api/CAssetManager
- 'assetManager'=>array(
- // 改变磁盘上的路径
- 'basePath'=>dirname(__FILE__).'/../../assets/',
- // 改变url
- 'baseUrl'=>'/web/assets/'
- ),
- 'errorHandler'=>array(// 用 'site/error' action 处理错误
- 'errorAction'=>'site/error',
- ),
- // 记录
- 'log'=>array(
- // 记录器的类
- 'class'=>'CLogRouter',
- // 在哪里存储日志
- 'routes'=>array(
- array(
- // 保存到文件中,其他选项是可用的
- 'class'=>'CFileLogRoute',
- // 什么内容保存到文件中? error 和 warning, info 和 trace 可以增加到这里
- 'levels'=>'error, warning',
- ),
- ),
- ),
- // 用户
- 'user'=>array(
- // 启用 cookie-based 验证
- 'allowAutoLogin'=>true,
- // 设置需要验证时用户被转到的 url
- // 使用 null 出现 43 HTTP 错误
- 'loginUrl'=>null,
- // 设置一个类的名字,
- // 这个类扩展自 CWebUser 并且保存在
- // protected/components/<classname> 中。
- 'class' => 'WebUser',
- ),
- // 数据库
- 'db'=>require(dirname(__FILE__).DIRECTORY_SEPARATOR.'db.php'),
- // 缓存
- 'cache'=>array(
- 'class'=>'A cache class, like: system.caching.CApcCache',
- ),
- 'session' => array( // memcache session cache
- 'class' =>'CCacheHttpSession',
- 'autoStart' => 1,
- 'sessionName' => 'frontend',
- 'cookieParams' => array('lifetime'=>'3600','path'=>'/','domain'=>'.test.com','httponly'=>'1'),
- 'cookieMode' => 'only',
- ),
- // url
- 'urlManager'=>array(
- // URL 格式。必须是 'path' 或 'get'。
- // path: index.php/controller/action/attribute/value
- // get: index.php?r=controller/action&attribute=value
- 'urlFormat'=>'path',
- // 显示为www.example.com/index.php/controller/action
- // 或www.example.com/controller/action
- 'showScriptName' => true,
- // 转向指定的 url 到你想要的 controller 的规则
- // 查阅www.yiiframework.com/doc/guide/topics.url
- 'rules'=>array(
- //www.example.com/home代替www.example.com/site/index
- 'home'=>'site/index',
- 'post/<id:\d+>'=>'post/show',
- ),
- ),
- // 你可以使用 scriptMap 来配置脚本来自哪里。
- //If you use the split configurations for development and production you can
- // have different maps in each and then just load the file and it'll
- // load the appropriate file depending on the configuration your running.
- // 对于一个生产环境的配置,如下
- 'clientScript'=>array(
- 'scriptMap'=>array(
- 'register.js'=>'site.min.js',
- 'login.js'=>'site.min.js',
- ),
- ),
- // 对于一个开发环境,可以这样做
- 'clientScript'=>array(
- 'scriptMap'=>array(
- 'register.js'=>'register.js',
- 'login.js'=>'login.js',
- ),
- ),
- ),
- );
params.php
- <?php
- return array(
- 'adminEmail'=>'info@example.com',
- 'pagesize'=>'100',
- 'pager'=>array(
- 'class'=>'PagerWidget',
- 'maxButtonCount'=>8,
- 'firstPageLabel'=>'首页',
- 'lastPageLabel'=>'末页',
- 'nextPageLabel'=>'下一页',
- 'prevPageLabel'=>'上一页',
- 'header'=>'',
- 'cssFile'=>false,
- ),
- );
index.php
配置环境常量,不同环境调用不同配置文件和调试级别。
- /**
- * 应用程序环境,可选:development,test,production,
- */
- defined('APP_ENV') or define('APP_ENV','development');
- // change the following paths if necessary
- if (APP_ENV == 'production') {
- error_reporting(0);
- $yii=dirname(__FILE__).'/../yii-svn/framework/yiilite.php';
- defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',1);
- } else {
- ini_set('error_reporting',E_ALL);
- ini_set('display_errors',1);
- $yii=dirname(__FILE__).'/../yii-svn/framework/yii.php';
- // remove the following lines when in production mode
- defined('YII_DEBUG') or define('YII_DEBUG',true);
- // specify how many levels of call stack should be shown in each log message
- defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
- }
- $config=dirname(__FILE__).'/protected/config/'.APP_ENV.'.php';
- require_once($yii);
- Yii::createWebApplication($config)->run();
development.php
开启weblog,profile,数据库性能显示,数据库查询参数记录,GII
- <?php
- return CMap::mergeArray(
- require(dirname(__FILE__).'/main.php'),
- array(
- 'components'=>array(
- // uncomment the following to use a MySQL database
- 'db'=>require(dirname(__FILE__).'/db.php'),
- 'log'=>array(
- 'class'=>'CLogRouter',
- 'routes'=>array(
- array(
- 'class'=>'CFileLogRoute',
- 'levels'=>'error, warning',
- ),
- array(
- 'class'=>'CProfileLogRoute',
- ),
- array(
- 'class'=>'CWebLogRoute',
- ),
- ),
- ),
- ),
- 'modules'=>array(
- // uncomment the following to enable the Gii tool
- 'gii'=>array(
- 'class'=>'system.gii.GiiModule',
- 'password'=>'sa',
- // If removed, Gii defaults to localhost only. Edit carefully to taste.
- 'ipFilters'=>array('127.0.0.1','::1'),
- ),
- ),
- )
- );
production.php
开启数据库结构缓存,开启CEAcceleratorCache,关闭错误显示
- <?php
- return CMap::mergeArray(
- require(dirname(__FILE__).'/main.php'),
- array(
- 'components'=>array(
- // uncomment the following to use a MySQL database
- 'db'=>require(dirname(__FILE__).'/db.php'),
- 'log'=>array(
- 'class'=>'CLogRouter',
- 'routes'=>array(
- array(
- 'class'=>'CFileLogRoute',
- 'levels'=>'error, warning',
- )
- ),
- ),
- 'cache'=>array(
- 'class'=>'system.caching.CEAcceleratorCache',
- ),
- ),
- )
- );
发表评论
-
Yii SendMail
2012-09-12 18:46 14951.下载拓展,解压至extesions/mailer htt ... -
集成PHPExcel
2012-09-06 15:24 14211.下载phpexcel 2.解压到/protecte ... -
YII contoller之间的方法调用 redirect
2012-07-31 15:23 9089一个contoller里怎么调用另一个controlle ... -
YII分页
2012-07-31 15:12 5122'defaultOrder'=>array('ti ... -
YII中的session和cookie
2012-07-31 15:09 1493一,在Yii中使用session 与原生态php5的se ... -
YII Behavior重用
2012-07-31 15:04 1339转载自:http://hudeyong926.iteye ... -
YII关联查询
2012-07-26 15:48 14102一、多表关联的配置 在我们使用 AR 执行关联查询之前 ... -
YII自带的模型验证
2012-07-26 11:49 2523// CValidator.php public st ... -
CDbCriteria 常用方法
2012-07-25 17:04 791/** * 传递变量 */ ... -
YII中的Asset
2012-07-24 17:51 2575简而言之,yii中protect目录下面的内容都是受保护的,但 ... -
YII RBAC
2012-07-19 17:42 6467自带的不带管理功能,直接用的是srbac 1.下载ex ... -
YII AR
2012-07-16 15:35 0Active Record(AR)是一种流行的对象关系映射(O ... -
YII中的模型验证
2012-07-16 15:35 953在一个web应用中,可能有多个地方需要进行验证。比如“注 ... -
YII的访问控制
2012-07-16 15:23 3233在Yii为Model生成的Controller中,有一个 ... -
YII中创建自己的widget
2012-07-16 13:46 13191.构建自己的widget testWidget.php 在 ... -
YII中加载静态页面
2012-07-16 13:31 4069在web应用中,我们经产更需要显示静态页,如“关于我们”等,这 ... -
YII中引入第三方的库
2012-07-16 11:29 13141首先要了解Root Alias 为方便起见,Yii 预定义了以 ... -
some note
2012-07-11 17:43 01.CDetailView和CGridView < ...
相关推荐
YII配置详解以及开发规范
商城开发的配置 yii2的 里面是代码可以详细的知道所有
netsteans yii 配色,提示 包含配置方案,yii-1.1.10.r3566.tar.gz
NULL 博文链接:https://hudeyong926.iteye.com/blog/1484367
本文详细分析了Yii配置文件的用法。分享给大家供大家参考。具体分析如下: Yii配置文件比ThinkPHP复杂多了,先把自己了解的配置记录下来,感兴趣的朋友可以参考一下: 复制代码 代码如下:<?php // 主配置文件 $...
本文实例讲述了Yii配置与使用memcached缓存的方法。分享给大家供大家参考,具体如下: 1. 下载memcached软件包,解压,把memcached.exe 放到随意一个地方,比如:d:/memcached/ 下。 2. 开始->运行->输入cmd,...
本文实例讲述了Yii2配置Nginx伪静态的方法。分享给大家供大家参考,具体如下: 主要检查以下代码: location / { # Redirect everything that isn't a real file to index.php try_files $uri $uri/ /index.php?$...
Yii2 Configloader:从配置文件和环境变量构建配置数组
YII2.0 支付宝接口完美配置,按照教程做百分百成功,教程链接www.phpman.cn/archives/67.html
yii2-advanced-api, 具有 RESTful API设置的Yii2高级模板 2高级应用程序模板中的 rest APIYii2高级应用程序模板,配置了 RESTful API 。 查看 http://budiirawan.com/setup-restful-api-yii2/ 了解更详细的解释安装 ...
yii2-dynamodb 会话yii2 session dynamodb 扩展是一个用于在 Amazon DynamoDB 中存储会话信息的组件此组件支持 Yii 版本 >= 2.0安装/配置要求从下载 AWS PHP SKD 并在 Yii2 框架中进行配置在 Yii 项目 Vendor 文件夹...
sass 和less 文件使用PHP 库转换 仅适用于使用PLUpload 库的YII2 上传文件 Plupload - 跨浏览器和平台上传 API 什么是Plupload Plupload 是一个用于处理文件上传的 JavaScript ...在您的 YII 配置文件 {app}/config/we
关于YII2代码配置那一部分,给出的是官方的链接,如果想要这部分,请不用下载,直接去官方阅读,以免浪费资源分哦
在工作中整理出的yii RBAC中Srbac的详细安装步骤,附截图。
主要介绍了Yii2简单实现多语言配置的方法,涉及Yii配置文件的设置及语言包的操作方法,需要的朋友可以参考下
本文从YII的目录结构开始分析,到入口文件分析,到路由设置详解,视图详解,十分全面的向我们展示了YII框架的方方面面,是篇非常不错的文章,这里推荐给大家。
主要介绍了Yii框架的路由配置方法,结合实例形式总结分析了Yii框架路由的常见配置与使用操作技巧,需要的朋友可以参考下