随笔分类 -  php

Yii2 自定义独立验证器
摘要:新建一个文件: ?php /** * author : forecho <caizhenghai@gmail.com> * createTime : 2015/7/1 14:54 * description: */ namespace common\helps; use yii\validators 阅读全文

posted @ 2016-02-04 16:53 yhdsir 阅读(1315) 评论(0) 推荐(0)

Yii2 配置 Nginx 伪静态
摘要:主要检查以下代码: location / { # Redirect everything that isn't a real file to index.php try_files $uri $uri/ /index.php?$args; } 完整代码: server { charset utf-8 阅读全文

posted @ 2016-02-04 16:49 yhdsir 阅读(4457) 评论(0) 推荐(0)

Yii2 使用 Beanstalk 队列系统
摘要:参考网址: Beanstalk:https://github.com/kr/beanstalkd Beanstalk console:https://github.com/ptrofimov/beanstalk_console Yii2-beanstalk:http://www.te.gd/exte 阅读全文

posted @ 2016-02-04 16:47 yhdsir 阅读(1021) 评论(0) 推荐(0)

Yii2 注册表单验证规则 手机注册时候使用短信验证码
摘要:public function rules() { return [ ['username', 'filter', 'filter' => 'trim'], ['username', 'required'], ['username', 'unique', 'targetClass' => '\com 阅读全文

posted @ 2016-02-04 16:44 yhdsir 阅读(1065) 评论(0) 推荐(0)

Yii2 高级模板 多域名管理问题
摘要:现在在网站中有这种情况,比如有一个 http://frontend.com/tv 需要根据判断用户的 User Agent ,如果用户是手机浏览器的话,则跳转到 http://mobile.com/tv。 frontend.com 所对应 frontend 应用 mobile.com 对应 mobi 阅读全文

posted @ 2016-02-04 16:43 yhdsir 阅读(720) 评论(0) 推荐(0)

PHP生成缩略图,控制图片质量,支持.png .jpg .gif
摘要:namespace common\components; class ResizeImageHelper { public $type;//图片类型 public $width;//实际宽度 public $height;//实际高度 public $resize_width;//改变后的宽度 pu 阅读全文

posted @ 2016-02-04 16:06 yhdsir 阅读(465) 评论(0) 推荐(0)

yii2-lock-form 也许这就是你想要的,阻止表单多次提交
摘要:是不是被用户的行为所困扰? 一个表单用户点击提交按钮了N次,这也导致了数据提交了N次。 为了此受到了测试的欺辱,受到了老板的批评? 不用怕,它就是来拯救你的。 第一步:打开命令行,敲入 composer require light\yii2-lock-form=~1.0.0 第二步:上个厕所 第三步 阅读全文

posted @ 2016-02-04 16:05 yhdsir 阅读(414) 评论(0) 推荐(0)

PHP日期与时间戳转换
摘要:设置时区 在php.ini中找到data.timezone去掉它前面的;号,然后设置data.timezone = "Asia/Shanghai"; 或者 ini_set('date.timezone','Asia/Shanghai'); 或者 date_default_timezone_set(' 阅读全文

posted @ 2016-02-04 16:02 yhdsir 阅读(568) 评论(0) 推荐(0)

PHP/Yii2操作Cookie,常见问题以及注意事项
摘要:设置Cookie PHP setcookie("name", "Larry",time()+3600 Yii2 $cookies = Yii::$app->response->cookies; $cookies->add(new \yii\web\Cookie([ 'name' => 'name', 阅读全文

posted @ 2016-02-04 15:57 yhdsir 阅读(1513) 评论(0) 推荐(0)

对称加密,API加密
摘要:用于API加密,双方约定好signature_key对请求的参数进行处理 处理步骤如下 把请求的数据生成为key=>value的形式,然后拼接生成arg_key arg_key加上双方约定的signature_key进行md5()加密 取得加密后的某一段字符 请求接口时在提交的数据中带上客户端生成t 阅读全文

posted @ 2016-02-04 15:53 yhdsir 阅读(423) 评论(0) 推荐(0)

yii2弹出层
摘要:bootstrap http://getbootstrap.com/javascript/#modals https://github.com/lichunqiang/yii2-sweet-submit 阅读全文

posted @ 2016-02-04 15:43 yhdsir 阅读(197) 评论(0) 推荐(0)

教你如何写一个 Yii2 扩展
摘要:前言 把一系列相关联的功能使用模块开发,好处多多,维护起来很方便,模块还可以单独发布出去,让下一个项目之间使用,真是方便。 下面我就写一个开发扩展的简单教程。 Gii gii 自带帮助我们生成一个基本的扩展文件结构,地址如下: www.xxx.com/gii/extension 先预览一下,成功之后 阅读全文

posted @ 2016-02-04 15:41 yhdsir 阅读(693) 评论(0) 推荐(0)

Yii2之事件处理
摘要:通过事件(Event)处理,可以在某个特定时刻执行指定的代码,可以解耦代码,同时也增加了可维护性,通常,事件在客户端软件中比较好理解,比如onClick,onFocus,当点击按钮,获取到焦点时执行指定代码。在PHP中,事件的处理可能不太好理解,但是,只要理清了事件处理的过程,一切都会变得简单: 1 阅读全文

posted @ 2016-02-04 15:38 yhdsir 阅读(2411) 评论(0) 推荐(1)

扩展 Yii2 自带的日志组件
摘要:<?php /** * author : forecho <caizhenghai@gmail.com> * createTime : 2015/12/22 18:13 * description: */ namespace common\components; use Yii; use yii\h 阅读全文

posted @ 2016-02-04 15:29 yhdsir 阅读(1019) 评论(0) 推荐(0)

Yii2 如何实现表单事件之 Ajax 提交
摘要:前言 Yii2 现在使用 JS 都必须要注册代码了。 要实现 Ajax 提交,有两种方法。一是直接在 ActiveForm 调用 beforeSubmit 参数,但是个人认为这样没有很好的把 JS 和 HTML 分开,所以我们这篇文章主要介绍第二种方法 - 外部写 JS 方法。 表单部分 <?php 阅读全文

posted @ 2016-02-04 15:22 yhdsir 阅读(2341) 评论(0) 推荐(0)

Yii2 如何更好的在页面注入CSS
摘要:首先 先添加一个widgets,代码如下(提示:使用时注意修改命名空间) <?php /** * User: yiqing * Date: 2014/12/15 * Time: 0:21 */ namespace year\widgets; use yii\widgets\Block; class 阅读全文

posted @ 2016-02-04 15:18 yhdsir 阅读(621) 评论(0) 推荐(0)

Yii2 如何更好的在页面注入JavaScript
摘要:首先 先添加一个widgets,代码如下(提示:使用时注意修改命名空间) <?php /** * User: yiqing * Date: 14-9-15 * Time: 下午12:09 */ namespace year\widgets; use yii\web\View ; use yii\wi 阅读全文

posted @ 2016-02-04 15:16 yhdsir 阅读(700) 评论(0) 推荐(0)

Yii2 提供可以用属性的方式去获取类的一个方法
摘要:刚开始用 Yii 的小朋友可能对下面的写法非常疑惑: public function actionIndex() { $user = User::find()->where(['name'=>'zhangsan'])->one(); $user->orders; // 关联查询订单表 } 去 Use 阅读全文

posted @ 2016-02-04 15:10 yhdsir 阅读(1235) 评论(0) 推荐(0)

Yii2 关于电子商务的开源项目
摘要:https://github.com/samdark/yii2-shop https://github.com/omnilight/yii2-shopping-cart https://github.com/yii2mod/yii2-cart https://github.com/funson86/ 阅读全文

posted @ 2016-02-04 15:08 yhdsir 阅读(328) 评论(0) 推荐(0)

yii 资料
摘要:https://github.com/forecho/awesome-yii2 会随时更新 链接:http://pan.baidu.com/s/1mgCKtUK 密码:t6t1 与《YII框架》不得不说的故事—基础篇 与《YII框架》不得不说的故事—高效篇 与《YII框架》不得不说的故事—安全篇 与 阅读全文

posted @ 2016-02-04 14:56 yhdsir 阅读(146) 评论(0) 推荐(0)

导航