摘要:1.在配置文件main-local.php components=>[]里面配置 以上配置,需要根据你的邮箱,进行配置。 2:在控制器里面或者在模型里面就可以调用了 3:要是QQ邮箱中开启POP3/SMTP服务 qq邮箱->设置-》账户 4:发送邮件后,就是这个样子了,注意对应一下上面的设置,就明白
阅读全文
摘要:1.在配置文件main-local.php components=>[]里面配置 ok,这样就可以发送邮件了 如需加载模板 把$mail= Yii::$app->mailer->compose(); 修改成 $mail= Yii::$app->mailer->compose('xiaoma',['a
阅读全文
摘要:$query = new Query; $query->select('ID, City,State,StudentName') ->from('student') ->where(['IsActive' => 1]) ->andWhere(['not', ['City' => null]]) ->
阅读全文
摘要:Rules验证规则: required : 必须值验证属性||CRequiredValidator 的别名, 确保了特性不为空. [['字段名1','字段名2'],required] //字段1 2 必填 [['字段名'],required,'requiredValue'=>'必填值','messa
阅读全文
摘要:常用查询: 更新: 删除: 批量插入: 查看执行sql
阅读全文
摘要:最近在拿 yii 2.0 开发ajax提交,在 post 请求接口时,提示数据无法验证,于是查询 yii 错误日志,发现错误为 exception ‘yiiwebBadRequestHttpException’ with message ‘Unable to verify your data sub
阅读全文
摘要:先在项目的根目录下复制一份 backend 为 api: cp backend/ api -r 拷贝 api 环境 cp -a environments/dev/frontend environments/dev/api cp -a environments/prod/frontend enviro
阅读全文
摘要:Yii2 Starter Kit(Yii2 开箱即用):https://github.com/trntv/yii2-starter-kit GetYii:https://github.com/iiYii/getyii Easy yii2 cms:https://github.com/noumo/ea
阅读全文
摘要:详情代码看这里:https://github.com/iiYii/getyii/commit/b8315d083d5d07969ac163205bf1452216246666 并且已经开发一个扩展了,欢迎大家使用,扩展地址:https://github.com/yiier/yii2-backup 来
阅读全文
摘要:新建一个文件: ?php /** * author : forecho <caizhenghai@gmail.com> * createTime : 2015/7/1 14:54 * description: */ namespace common\helps; use yii\validators
阅读全文
摘要:主要检查以下代码: location / { # Redirect everything that isn't a real file to index.php try_files $uri $uri/ /index.php?$args; } 完整代码: server { charset utf-8
阅读全文
摘要:参考网址: Beanstalk:https://github.com/kr/beanstalkd Beanstalk console:https://github.com/ptrofimov/beanstalk_console Yii2-beanstalk:http://www.te.gd/exte
阅读全文
摘要:public function rules() { return [ ['username', 'filter', 'filter' => 'trim'], ['username', 'required'], ['username', 'unique', 'targetClass' => '\com
阅读全文
摘要:现在在网站中有这种情况,比如有一个 http://frontend.com/tv 需要根据判断用户的 User Agent ,如果用户是手机浏览器的话,则跳转到 http://mobile.com/tv。 frontend.com 所对应 frontend 应用 mobile.com 对应 mobi
阅读全文
摘要:是不是被用户的行为所困扰? 一个表单用户点击提交按钮了N次,这也导致了数据提交了N次。 为了此受到了测试的欺辱,受到了老板的批评? 不用怕,它就是来拯救你的。 第一步:打开命令行,敲入 composer require light\yii2-lock-form=~1.0.0 第二步:上个厕所 第三步
阅读全文
摘要:设置时区 在php.ini中找到data.timezone去掉它前面的;号,然后设置data.timezone = "Asia/Shanghai"; 或者 ini_set('date.timezone','Asia/Shanghai'); 或者 date_default_timezone_set('
阅读全文
摘要:设置Cookie PHP setcookie("name", "Larry",time()+3600 Yii2 $cookies = Yii::$app->response->cookies; $cookies->add(new \yii\web\Cookie([ 'name' => 'name',
阅读全文
摘要:bootstrap http://getbootstrap.com/javascript/#modals https://github.com/lichunqiang/yii2-sweet-submit
阅读全文
摘要:前言 把一系列相关联的功能使用模块开发,好处多多,维护起来很方便,模块还可以单独发布出去,让下一个项目之间使用,真是方便。 下面我就写一个开发扩展的简单教程。 Gii gii 自带帮助我们生成一个基本的扩展文件结构,地址如下: www.xxx.com/gii/extension 先预览一下,成功之后
阅读全文
摘要:通过事件(Event)处理,可以在某个特定时刻执行指定的代码,可以解耦代码,同时也增加了可维护性,通常,事件在客户端软件中比较好理解,比如onClick,onFocus,当点击按钮,获取到焦点时执行指定代码。在PHP中,事件的处理可能不太好理解,但是,只要理清了事件处理的过程,一切都会变得简单: 1
阅读全文