手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表分类:PHP

composer 加速插件

先说再写:

全局更新
  1. composer global require hirak/prestissimo  

即使你用了这玩意,还是得先用国内的源,否则所谓的加速也是白搭。
GITHUB在这里:https://github.com/hirak/prestissimo
看官网的介绍,提升有10倍,虽然 我们在国内没有这么高的提速,但感觉上还是快了不少(应该不是安慰剂)
 

mysql 函数与 pdo函数的对比及使用

mysql在升到php7后,原有的mysql_*函数都没有了,如果要迁移,可以参考 这一篇:https://stackoverflow.com/questions/36073703/mysql-to-pdo-comparison-table

介绍的比较详细,比如mysql常用的几个函数的转换写法,这里都有了:
随便截一点内容,详细的还是去网站看:
 

MySQL_ Original Driver to PDO Comparative Table

Introduction:

This table is not intended to be a tutorial or a guide to PDO, but to provide a correspondence between MySQL_ and PDO. So, some important PDO commands are missing, if they don't have a MySQL_ correspondence.

Among these omitted commands, there is a major PDO feature, the prepared statements. I strongly recommend to use it, also if only cited in this guide.

This is a very extended answer. I'm sorry for the low quality of spelling (I'm not english) and for the typos. I will try to correct and improve it in the next few days. Any suggestion or contribution is welcome.

Naming Conventions:

To avoid misunderstanding, in this answer I use:

In PDO, we have two major object types, the PDOObject (the connection between PHP and a database server) and the PDOStatement (a prepared statement and, after the statement is executed, an associated result set). In this answer, variable names are:

  • $dbh, refer to PDOobject;
  • $stmt, refer to PDOStatement.
 
 

yii2终于有自己的队列了!!!

当然 ,之前yii2有一个queue,这个queu简单到只有一个run/job,其他都没有。这回终于来一个完善的了。说实话,有时候用laravel,就是因为想用他的queue。现在终于不用纠结了!

再细看一下他的composer.json。。。还是逃不脱SF的大坑!不过总算是有队列了,管它呢。这年头,所有框架最后都会被SF大一统么?

先到这里看一下教程:https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/README.md

然后再回到:https://github.com/yiisoft/yii2-queue ,下载代码吧,真正使用也简单,php composer.phar require --prefer-dist yiisoft/yii2-queue,就完事了!

不过这个玩意,估计在windows下面是无效的,常用方法有:

PHP代码
  1. // Push a job into queue and get massage ID.  
  2. $id = Yii::$app->queue->push(new SomeJob());  
  3.   
  4. // The job is waiting for execute.  
  5. Yii::$app->queue->isWaiting($id);  
  6.   
  7. // Worker gets the job from queue, and executing it.  
  8. Yii::$app->queue->isReserved($id);  
  9.   
  10. // Worker has executed the job.  
  11. Yii::$app->queue->isDone($id);  

 

估计以后的项目,默认就直接引用:yiisoft/yii2 , yiisoft/yii2-queue了!

 

Tags: yii, queue

推荐阅读:PHP

看这里: https://blog.jetbrains.com/phpstorm/2017/06/php-annotated-monthly-june-2017/

其实在blog.jetbrains.com/phpstorm上,有很多PHP的使用方法和IDE的奇技淫巧。比如教你怎么远程debug之类的
我先贴点原文中的链接。如果要看更多,可以点击上面的链接
 

PHP 7.2 will have some great new features, keep your eye on this blog for a roundup once I’ve had a chance to look at the alpha in the coming weeks.

Other good posts on PHP and general development this month:

Frameworks and Libraries

We’ve got the usual slew of Laravel and Zend Framework posts, along with some interesting posts for WordPress, Yii and some more useful articles on Composer and Packagist.

Yii

Laravel

Zend Framework

Symfony

Other

Community, Career, and Events

There was an interesting interview with Taylor Otwell, creator and lead developer of Laravel tells us why Taylor Otwell Wants You To Build Your PHP Apps On Laravel. I also enjoyed an interview with Anna Filina On PHP Trainings And Future Of PHP Frameworks.

An interesting question is posed in Can 9-to-5 Developers Be Good Developers? While I disagree vehemently with some of the points made in the article, it makes for an interesting discussion.

This month I’ll be at PHP South Coast in Portsmouth this week, and DPC in Amsterdam at the end of the month. Make sure you come and say “Hi!” if you see me at any events.

好东西实在太多。。。
 

yii2 orwhere andwhere的复杂写法

 如果仅仅是多个orwhere条件,其实就是默认的andWhere和orWhere的标准写法,但如果条件是:

queue_name != '' and ( queue_status = '' or (queue_status ='error' and retry = 0))这样的要求,用Yii AR 就比较难写了。
demo如下:
 
PHP代码
  1. $files = XXXX::find()  
  2.                ->andWhere(['<>''queue_name'''])  
  3.                ->andWhere(['or',  
  4.                    ['queue_status' => ''],  
  5.                    [  
  6.                        'and',  
  7.                        ['queue_status' =>'error'],  
  8.                        ['retry' => 0]  
  9.                    ]  
  10.                ])  
  11.                ->all();  
其实也就这样了。。
重点:
1、不等于的写法
2、或条件其实不是用orWhere,而是用andWhere
3、如果orWhere条件中有双重条件,得使用数组,并使用and进行连接
 
BTW:今天是PHPcon的第一天,然而我却没空去。我是陪读的书童~~~