ITeye博客

2015 年文章归档

共 47 篇文章

TP在APP_DEBUG=false的情況下,CLI和WEBSITE會共用同一個~runtime.php導致出錯的問題解決辦法

TP若使用了 define('APP_DEBUG',false); 會生成./Runtime/~runtime.php 緩存文件,以後每次調用都會用這個文件來處理 但是若一個項目又使用了CLI,CLI生成的./Runtime/~runtime.php 文件跟website是同一個文件,而且cli生成的./Runtime/~runtime.php文件少了一些定義,例如__ROOT__ if(!IS_CLI) { // 当前文件名 if(!defined('_PHP_FILE_')) { if(IS_CGI) { //CGI/FASTCGI模式下 $_temp = explode('.php',…

2015-12-14 11:43 · php · thinkphp · PHP · thinkphp

git pull 失败的解决办法

参考 : http://www.cnblogs.com/leealways87/archive/2013/04/14/3020840.html 执行sudo git pull 提示 Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 做以下操作: git config --global user.name davidhuang git …

2015-11-30 15:42 · Git

winston log split by date的解决方案

winston 是node.js的日志管理工具,但是它的api是按照文件大小来切割文件,而不是按照日期来切割的。如何做到按日期存储日志呢? 参考资料 http://stackoverflow.com/questions/11403953/winston-how-to-rotate-logs https://github.com/winstonjs/winston/issues/10 https://github.com/winstonjs/winston/pull/120/files https://github.com/winstonjs/winston/pull/205

2015-11-25 11:56 · node.js · nodeJs

git fetch 失敗提示insufficient permission for adding an object to repository db

參考:http://stackoverflow.com/questions/6448242/git-push-error-insufficient-permission-for-adding-an-object-to-repository-datab 執行 git fetch,提示 insufficient permission for adding an object to repository database 解決辦法: cd .git/objects ls -al sudo chown -R yourname:yourgroup *

2015-11-25 09:50 · git · Git

TP3.2的try catch如何捕获异常

参考:http://www.oschina.net/question/723831_218382 public function t(){ try { throw new \Exception("haha"); }catch (Exception $e){ dump($e); } } 以上catch无法捕捉到,会出现ERROR的页面。因为catch (Exception $e){捕获的是当前module的Exception类,而不是\Exception,因此需要改成 public function t(){ try { E("errr"); }catch (\Exception $e){ d…

2015-10-29 17:16 · thinkphp · PHP · thinkphp

redis 模糊删除key

redis-cli KEYS "pattern" | xargs redis-cli DEL Redis keys命令支持模式匹配,但是del命令不支持模式匹配,有时候需要根据一定的模式来模糊删除key,这时只能结合shell命令来完成了。 具体命令是: redis-cli KEYS "pattern" | xargs redis-cli DEL 其中pattern是keys命令支持的模式,这样就可以模糊删除key了。服务器上测试删除150万条数据的效率也是很高的。 所有的Redis命令可以在这里找到:http://redis.io/commands KEYS命令:http://redis.…

2015-10-23 14:48 · redis · Redis

nodejs程序后台一直运行

来源:http://materliu.github.io/all/web/nodejs/2014/04/16/nodejs_serve_background_run.html nodejs程序后台一直运行 nohup node server.js & 涨姿势: unix/Linux下一般想让某个程序在后台运行,很多都是使用 & 在程序结尾来让程序自动运行。比如我们要运行mysql在后台: /usr/local/mysql/bin/mysqld_safe --user=mysql & 但是我们很多程序并不象mysqld一样可以做成守护进程,可能我们的程序只是普通程序而已,一般这种程序即使使用 …

2015-10-22 09:57 · node.js · node.js

解决nodemailer发送email提示Invalid login 的问题

上代码 var nodemailer = require('nodemailer'); // create reusable transporter object using SMTP transport var transporter = nodemailer.createTransport({ service: 'Gmail', auth: { user: 'xxx@xxx', pass: 'xxxx' } }); transporter.sendMail({ from: 'xxx', to: 'xxxx', subject: 'hello', text: 'hello world!' …

2015-09-24 10:57 · node.js · node.js

node.js获取php curl post数据req.body为空的处理

node使用了express4和body-parser来解析php curl的数据,但是获取的req.body是{},设置了header 前提知识: body-parser不支持解析multi/form-data的功能,如果是传递二进制数据或者文件上传,就不能用它了。 Node.js body parsing middleware. This does not handle multipart bodies, due to their complex and typically large nature. For multipart bodies, you may be interested…

2015-09-22 11:43 · php · node.js · PHP · node.js

使用mysql merge engine 注意点

参考http://blog.csdn.net/qmhball/article/details/7499432 建3个表。merge engine的t表是无法打开的提示1168的mysql错误 关键在于,使用merge的表结构必须和unin的表结构一致。他给出的sql中多了个 not null 属性。 CREATE TABLE `t1` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `log` varchar(45) , PRIMARY KEY (`id`) ) ENGINE=MyISAM; CREATE TABLE `t2`( `id` i…

2015-08-27 14:46

yaf namespace的使用

yaf支持namespace。在php.ini 中添加 yaf.namespace=1 就可以启动namespace 但是如果开了namespace就不能再使用非namespace的写法了。 <?php define('ROOT_PATH', realpath(dirname(dirname(__FILE__)))); define('APPLICATION_PATH', ROOT_PATH . '/application'); header('content-Type:text/html;charset=utf-8;'); $application = new Yaf_Applicatio…

2015-08-27 11:32 · php · yaf · Yaf

yaf 添加phpunittest

首先要讓php在cli下支持yaf wamp下打開D:/wamp/bin/php/php5.5.12/php.ini 在extension=php_xsl.dll下面輸入 extension=php_yaf.dll yaf.environ=dev ;yaf.use_namespace=0 然後重啟apache。 在項目目錄下新建一個test的入口文件,/public/indexTest.php <?php define('ROOT_PATH', realpath(dirname(dirname(__FILE__)))); define('APPLICATION_PATH', ROOT_PAT…

2015-08-21 11:16 · php · yaf · PHP · Yaf

thinkphp socket to support sso (php socket 不稳定,不建议使用)

cli code #!/bin/bash filepath=$(cd "$(dirname "$0")"; pwd) cd $filepath #running status:sso.lock,stop status:ssostop.lock TMPFILE=$filepath/sso.lock STOPFILE=$filepath/ssostop.lock runCLI(){ touch $TMPFILE echo "sso server process started.\n" logname="sso_"$(date +%Y%m%d); su www-data -c "php index…

2015-08-18 14:06 · php · Socket · PHP · SSO

kue api文档说明

创建job queue job队列 var jobs = kue.createQueue(); ##创建job var job = queue.create('email', { title: 'welcome email for tj' , to: 'tj@learnboost.com' , template: 'welcome-email' }).save( function(err){ if( !err ) console.log( job.id ); }); ##设置job优先级 queue.create('email', { title: 'welcome email for tj…

2015-08-12 16:56 · node.js · node.js

node.js的异常处理-domain

参考: https://cnodejs.org/topic/516b64596d38277306407936 采用uncaughtException,可以捕获到未正式捕获到的异常,但是无法处理。只能记录log。 process.on('uncaughtException', function (err) { logger.error(err); }); 于是有了domain。捕获异步回调中出现的异常。 https://nodejs.org/api/domain.html

2015-08-12 15:41 · node.js · node.js

redis 入門筆記

String ##set get set mykey "abc" get mykey set counter 100 ##incr counter return 101 ##incrby counter 10 return 111 ##expire 設置超時時間 設置超時時間10秒。10秒後會被自動刪除 EXPIRE mykey 10 ##EXPIREAT 與EXPIRE 類似,不同的是EXPIREAT用的是 UNIX 时间戳 Unix timestamp 。 ##PERSIST 移除key的生存時間 PERSIST mykey exists 判斷key是否存在 KEYS 查找所有符合給定模…

2015-08-11 17:19 · redis · Redis

ubuntu下设置虚拟domain

参考:http://www.cnblogs.com/ylan2009/archive/2012/02/25/2368028.html ln 命令的学习 http://blog.csdn.net/conowen/article/details/7251128 什么是vhost? Vhost是apache服务的虚拟主机,通过配置不同的vhost,可以在同一台apache主机上运行不同的web应用。 如果你是一位php学习者,你想通过两个不同的应用test1和test2学习不同的知识,或者进行对比测试。你就可以创建两个test1目录和test2目录,里面分别存放test1和test2两个工程。通过…

2015-08-05 14:20 · apache · Ubuntu · vhost

ubuntu下安装yaf框架

参考 http://yaf.laruence.com/manual/yaf.install.html yaf下载: https://pecl.php.net/package/yaf 版本选择 2.3.5以下版本适用于php5.2 ~ 5.x 的环境 3.0 以上版本适用于php7及以上环境 首先要找到php的安装目录,执行info.php,查看php路径 [code="java"] Configuration File (php.ini) Path /etc/php5/apache2 [/code] 再查找phpize的地址在哪里, [code="java"] whereis phpize …

2015-08-05 11:46 · yaf · PHP · Yaf

prediction.io的安裝過程

今天終於將prediction.io裝上VM了。遇到好多問題。 參考: https://docs.prediction.io/install/ https://docs.prediction.io/install/install-linux/(ubuntu獨立安裝看這裡,推薦) https://docs.prediction.io/start/download/ 如果DB用的不是hbase。如mysql,就不需要安裝Elasticsearch pio/conf/pio-env.sh 要將DATABASE的設置改成mysql。 最後用pio status 檢查是否安裝成功。 pio命令要執行 …

2015-07-30 17:25 · big data · 大数据 · 推荐系统

ubuntu安裝redis

安裝redis的時候需要make工具。ubuntu下沒有。需要參考以下安裝 $ sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make $ sudo apt-get update Then, installing Ubuntu Make: $ sudo apt-get install ubuntu-make 來源: https://wiki.ubuntu.com/ubuntu-make 之後在redis目錄執行make 還是失敗了。因為沒有安裝cc,繼續安裝: sudo apt-get install gcc 再次make。又failed…

2015-07-30 15:30 · linux · redis · Redis · Ubuntu