随笔分类 -  YII 2.0

摘要:如果debug条不见了,很有可能是因为runtime这个folder的访问权限有问题造成,修改一下这个文件夹的权限就可以解决问题了。 阅读全文
posted @ 2015-09-21 16:41 S大好人S 阅读(335) 评论(0) 推荐(0)
摘要:在写codeception functional test 时测试中如果包含post请求,那么我们就需要调用函数sendPost。默认情况下的functional tester中是不包含该函数的,需要enable这写函数,具体方法如下:在functional.suite.yml文件中:class_n... 阅读全文
posted @ 2015-08-28 13:39 S大好人S 阅读(337) 评论(0) 推荐(0)
摘要:YII验证身份值可以设置一个MODEL来做为身份认证登陆的数据来源,这样当一个WEB应用中有两个角色并且都使用ACCESS TOKEN登陆时就会错误的把另一角色列为未认证的用户。解决方法是修改框架认证部分的代码如下:1. 在WEB CONFIG中设置另一个TOKEN的名字,注意如果有两种角色,那么必... 阅读全文
posted @ 2015-08-27 14:37 S大好人S 阅读(630) 评论(0) 推荐(0)
摘要:YII提供的可更改异常返回的格式很有限而且很不灵活,在这里我们需要修改框架的代码来实现。既然是异常,那么我们就要修改响应的文件:/home/gcheng/workShop/basic/vendor/yiisoft/yii2/web/ErrorHandler我们的目标是把异常格式改为如下格式:{ ... 阅读全文
posted @ 2015-08-25 16:49 S大好人S 阅读(641) 评论(0) 推荐(0)
摘要:http://askubuntu.com/questions/350942/cannot-get-mcrypt-for-php5可以解决问题,但是详细还要研究一下 阅读全文
posted @ 2015-08-21 21:49 S大好人S 阅读(110) 评论(0) 推荐(0)
摘要:YII是提供修改输出参数格式的,但是可供用户定制化的空间非常小。如想把prefix中的userID和ip分别插入到数据库中不同的两列,就需要需改框架文件:/basic/vendor/yiisoft/yii2/log/Target与/basic/vendor/yiisoft/yii2/log/DbTa... 阅读全文
posted @ 2015-08-20 14:58 S大好人S 阅读(281) 评论(0) 推荐(0)
摘要:在配置文件中修改用于储存acess token的类 'user' => [ 'identityClass' => 'app\models\Customer', 'enableAutoLogin' => false,//disable the ... 阅读全文
posted @ 2015-08-20 12:34 S大好人S 阅读(1726) 评论(0) 推荐(0)
摘要:$sql = 'INSERT INTO `table1`(`customerID`, `advertisementID`, `consumedStatus`, `consumedTime`) VALUES (:customerID,:advertisementID,:con... 阅读全文
posted @ 2015-07-26 22:56 S大好人S 阅读(665) 评论(0) 推荐(0)
摘要:例1$connection=Yii::app()->db;$sql="SELECT*FROM`project`ORDERBYidDESC";$command=$connection->createCommand($sql);$result=$command->queryAll();print_r($... 阅读全文
posted @ 2015-07-25 15:21 S大好人S 阅读(156) 评论(0) 推荐(0)
摘要:[ 'class' => 'app\actions\GzhAppFormatOutput',//此处要注意actions一定是GzhAppFormatOutput.php所在的文件夹 'objectsToFormat' => 'abc',... 阅读全文
posted @ 2015-07-20 21:14 S大好人S 阅读(243) 评论(0) 推荐(0)
摘要:在写UNIT TEST的时候,难免有的时候会遇到错误,遇到错误就需要把变量值打印出来:可以在代码中加:codecept_debug($returnMessage);然后在运行UNIT TEST的时候使用:codecept_debug($returnMessage)即可 阅读全文
posted @ 2015-07-09 15:46 S大好人S 阅读(397) 评论(0) 推荐(0)
摘要:1:首先按照官方指导安装所需组件 For the local installation use following commands: composer require "codeception/codeception=2.0.*" composer require "codeception/... 阅读全文
posted @ 2015-07-02 16:36 S大好人S 阅读(423) 评论(0) 推荐(0)
摘要:Step1:Make a folder named "components" in your project root folder.step2:write your custom component inside components folder eg:MyComponent.phpnamesp... 阅读全文
posted @ 2015-06-30 19:38 S大好人S 阅读(348) 评论(0) 推荐(0)
摘要:使用YII2.0提供的AR访问数据库时,功能限制较大,只好结合SQL语句如:GzhAd::findBySql('SELECT * FROM gongZhongHaoInfo where advertisementID > :start && advertisementID $start, ':en... 阅读全文
posted @ 2015-06-25 20:46 S大好人S 阅读(364) 评论(0) 推荐(0)
摘要:在CONTROLLER里边加上如果指示指定一个函数那么可以使用: \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;如果想整个应用都返回JSON格式,那么可以在component中设置: 'response'... 阅读全文
posted @ 2015-06-24 16:11 S大好人S 阅读(5878) 评论(0) 推荐(0)
摘要:1:修改Url Manager,例如下边这个例子是在customer这个控制器中添加一个新的action叫token 1 'urlManager'=>array( 2 'enablePrettyUrl'=>true, 3 'showSc... 阅读全文
posted @ 2015-06-22 16:55 S大好人S 阅读(278) 评论(0) 推荐(0)
摘要:1.安装响应插件2.在header 里边定义为: ACCEPTapplication/json; q=1.0, */*; q=0.1 阅读全文
posted @ 2015-06-22 16:04 S大好人S 阅读(247) 评论(0) 推荐(0)
摘要:'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => false,//disable the cookie login ], //disable session 'session' => array ( 'au... 阅读全文
posted @ 2015-06-22 11:53 S大好人S 阅读(720) 评论(0) 推荐(0)
摘要:1.在YII首页在框架里边用yii debuggeryii::trace('message');yii::log('message'); 阅读全文
posted @ 2015-06-22 11:40 S大好人S 阅读(689) 评论(0) 推荐(0)