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

几个常见的 Composer 国内镜像

现在写PHP好象不用Composer总感觉有点Low了吧?好吧,即使这样,你在使用composer update的时候是不是也发现网速、进度low的不行。一个composer update要等半天。不说这个吧,你就是一个composer init也要等半天,这只是个空项目,你都要等这么久?composer 如果不加-vvv参数,你就感觉整个世界都停在那里了。所以,如果连接原始的composer还是加个-vvv参数吧

国内常见镜像有三个:

XML/HTML代码
  1. http://pkg.phpcomposer.com/  
  2. https://toran.reimu.io/  
  3. http://packagist.cn/  

 

使用方法很简单一种是在~/.composer/config.json中加入相应的信息,一种是在当前项目的composer.json中加入:

JavaScript代码
  1. "repositories": [  
  2.     {"type""composer""url""http://pkg.phpcomposer.com/repo/packagist/"},  
  3.     {"packagist"false}  
  4. ]  

 

加入的时候注意语法,如果是json的最后一个元素,记得不要加","即可,否则 会报错

OK这样就可以了,尽情的尝试吧(packagist.cn更新的有点慢,toran.reimu.io 是https的,如果你本机openssl版本低可能会更新失败)。好象话这么一说,只能用pkg.phpcomposer.com的源了(嗯,忍忍吧,如果他不能用,你再换)

更新:composer 源 

 

 

Tags: composer

PHP Warning: Module 'modulename' already loaded in Unknown on line 0

出现标题这样的错误大概是:

1、模块加载了两次,所以php -i|grep Configure,看一下配置文件和配置include的目录,对于这些文件中是否有同名的module

2、动态加载模块时,模块的目录下与php.ini中都有一个同名so

知道上述的问题就好办了,先看php配置文件和include目录下的文件,先整理内容。然后查看extension_dir,看看这个目录下的文件与include中的文件引用路径是否一致。

 

 

array_key_exists 和 isset

看到andot的hprose中有使用array_key_exists,就想问为什么不用isset,再一想哦。isset不能判断$a['xxx'] = null的情况。这时候看了一下评论,有人建议用isset() || array_key_exists来辅助判断,说是性能有大提升。

于是写了点代码测试,果然:

XML/HTML代码
  1. count array: 999900 ; loop :100000  
  2. $array['109011'] = 109011;  
  3. 1. array_key_exists(109011,$array);  
  4.   bool(true)  
  5.   0.021718   
  6.   
  7. 2. isset($array['109011']);  
  8.   bool(true)  
  9.   0.004888   
  10.   
  11. 3. isset( $array['109011'] ) || array_key_exists( '109011', $array )  
  12.   bool(true)  
  13.   0.005100   
  14.   
  15.   
  16. count array: 999900 ; loop :100000  
  17. $array['109011'] = null;  
  18. 1. array_key_exists(109011,$array);  
  19.   bool(true)  
  20.   0.026091   
  21.   
  22. 2. isset($array['109011']);  
  23.   bool(false)  //注意看这里
  24.   0.006697   
  25.   
  26. 3. isset( $array['109011'] ) || array_key_exists( '109011', $array )  
  27.   bool(true)  
  28.   0.026621   

基本上,在$a['x'] 不是null的情况下,性能提升4倍左右 ,如果该值是null,这损耗可以接受。

数组长度是999900,循环100000次

所以以后代码还是 isset($a[$key])||array_key_exists($key,$a) 比较好。
当然,如果你平时处理isset($_GET['xxx'])的时候,不需要用array_key_exists的,因为URL中都是string

 

又一个不错的UI皮肤

平时的工作中,除了bootstrap,其实还是有一些其他的皮肤是可以尝试的,比如这个“http://semantic-ui.com/”,你就可以看到与bootstrap等不同的效果。

semantic-ui准备了一些常用的小效果,而且自带了一些小皮肤,比如github的效果,比如bootstrap,twitter的小效果,你在使用中会发现它的好的

不多介绍,直接去官网看吧。如果你偷懒,就用这个链接下载吧:https://github.com/Semantic-Org/Semantic-UI/archive/1.10.2.zip

官网:http://semantic-ui.com/

github: https://github.com/semantic-org/semantic-ui/

Tags: semantic, bootstrap

yiisoft/yii2 2.0.2 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found

在composer update项目的时候,报了如标题一样的错误,当然这个错误 有一大堆

XML/HTML代码
  1. composer update  
  2. Loading composer repositories with package information  
  3. Updating dependencies (including require-dev)  
  4. Your requirements could not be resolved to an installable set of packages.  
  5.   
  6.   Problem 1  
  7.     - The requested package bower-asset/jquery could not be found in any version, there may be a typo in the package name.  
  8.   Problem 2  
  9.     - Installation request for yiisoft/yii2 dev-master -> satisfiable by yiisoft/yii2[dev-master].  
  10.     - yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.  
  11.   Problem 3  
  12.     - yiisoft/yii2 2.0.x-dev requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.  
  13.     - yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.  
  14.     - Removal request for yiisoft/yii2-imagine == 2.0.9999999.9999999-dev  
  15.     - yiisoft/yii2-imagine 2.0.0 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].  
  16.     - yiisoft/yii2-imagine 2.0.0-rc requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].  
  17.     - yiisoft/yii2-imagine 2.0.1 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].  
  18.     - yiisoft/yii2-imagine 2.0.2 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].  
  19.     - Removal request for yiisoft/yii2-imagine == 9999999-dev  
  20.     - Installation request for yiisoft/yii2-imagine * -> satisfiable by yiisoft/yii2-imagine[2.0.0, 2.0.0-rc, 2.0.1, 2.0.2, 2.0.x-dev, dev-master].  
  21.   
  22. Potential causes:  
  23.  - A typo in the package name  
  24.  - The package is not available in a stable-enough version according to your minimum-stability setting  
  25.    see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.  
  26.   
  27. Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.  
看上去好纠结,但其实官方有过提示,通过查看:http://www.yiiframework.com/doc-2.0/guide-start-installation.html#installing-via-composer,可知,只要运行:
XML/HTML代码
  1. composer global require "fxp/composer-asset-plugin:1.0.0"  
问题解决。
XML/HTML代码
  1. composer update  
  2. Loading composer repositories with package information  
  3. Updating dependencies (including require-dev)  
  4. Reading bower.json of bower-asset/jquery.inputmask (3.1.47)  
  5. Could not fetch https://api.github.com/repos/RobinHerbots/jquery.inputmask/contents/bower.json?ref=9ff37e85bc2fa2350475c4a7fa60aa20cd211481, enter your GitHub credentials to go over the API rate limit  
  6. The credentials will be swapped for an OAuth token stored in /Users/*******/.composer/auth.json, your password will not be stored  
  7. To revoke access to this token you can visit https://github.com/settings/applications  
  8. Username:********  
  9. Password:********  
  10. Token successfully created  
  11. Reading bower.json of bower-asset/jquery.inputmask (3.1.44)  
  12. 。。。。。。。此处省略500字
 
 
 
 

Tags: yii2