Submitted by gouki on 2015, June 15, 1:47 PM
现在写PHP好象不用Composer总感觉有点Low了吧?好吧,即使这样,你在使用composer update的时候是不是也发现网速、进度low的不行。一个composer update要等半天。不说这个吧,你就是一个composer init也要等半天,这只是个空项目,你都要等这么久?composer 如果不加-vvv参数,你就感觉整个世界都停在那里了。所以,如果连接原始的composer还是加个-vvv参数吧
国内常见镜像有三个:
XML/HTML代码
- http://pkg.phpcomposer.com/
- https://toran.reimu.io/
- http://packagist.cn/
使用方法很简单一种是在~/.composer/config.json中加入相应的信息,一种是在当前项目的composer.json中加入:
JavaScript代码
- "repositories": [
- {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},
- {"packagist": false}
- ]
加入的时候注意语法,如果是json的最后一个元素,记得不要加","即可,否则 会报错
OK这样就可以了,尽情的尝试吧(packagist.cn更新的有点慢,toran.reimu.io 是https的,如果你本机openssl版本低可能会更新失败)。好象话这么一说,只能用pkg.phpcomposer.com的源了(嗯,忍忍吧,如果他不能用,你再换)
更新:composer 源
Tags: composer
PHP | 评论:0
| 阅读:23375
Submitted by gouki on 2015, March 12, 10:36 PM
出现标题这样的错误大概是:
1、模块加载了两次,所以php -i|grep Configure,看一下配置文件和配置include的目录,对于这些文件中是否有同名的module
2、动态加载模块时,模块的目录下与php.ini中都有一个同名so
知道上述的问题就好办了,先看php配置文件和include目录下的文件,先整理内容。然后查看extension_dir,看看这个目录下的文件与include中的文件引用路径是否一致。
PHP | 评论:0
| 阅读:21431
Submitted by gouki on 2015, March 6, 2:19 PM
看到andot的hprose中有使用array_key_exists,就想问为什么不用isset,再一想哦。isset不能判断$a['xxx'] = null的情况。这时候看了一下评论,有人建议用isset() || array_key_exists来辅助判断,说是性能有大提升。
于是写了点代码测试,果然:
XML/HTML代码
- count array: 999900 ; loop :100000
- $array['109011'] = 109011;
- 1. array_key_exists(109011,$array);
- bool(true)
- 0.021718
-
- 2. isset($array['109011']);
- bool(true)
- 0.004888
-
- 3. isset( $array['109011'] ) || array_key_exists( '109011', $array )
- bool(true)
- 0.005100
-
-
- count array: 999900 ; loop :100000
- $array['109011'] = null;
- 1. array_key_exists(109011,$array);
- bool(true)
- 0.026091
-
- 2. isset($array['109011']);
- bool(false) //注意看这里
- 0.006697
-
- 3. isset( $array['109011'] ) || array_key_exists( '109011', $array )
- bool(true)
- 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
PHP | 评论:0
| 阅读:19374
Submitted by gouki on 2015, February 27, 10:59 PM
平时的工作中,除了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
PHP | 评论:0
| 阅读:20799
Submitted by gouki on 2015, February 15, 11:52 PM
在composer update项目的时候,报了如标题一样的错误,当然这个错误 有一大堆
XML/HTML代码
- composer update
- Loading composer repositories with package information
- Updating dependencies (including require-dev)
- Your requirements could not be resolved to an installable set of packages.
-
- Problem 1
- - The requested package bower-asset/jquery could not be found in any version, there may be a typo in the package name.
- Problem 2
- - Installation request for yiisoft/yii2 dev-master -> satisfiable by yiisoft/yii2[dev-master].
- - yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- Problem 3
- - yiisoft/yii2 2.0.x-dev requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- - yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- - Removal request for yiisoft/yii2-imagine == 2.0.9999999.9999999-dev
- - yiisoft/yii2-imagine 2.0.0 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].
- - yiisoft/yii2-imagine 2.0.0-rc requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].
- - yiisoft/yii2-imagine 2.0.1 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].
- - yiisoft/yii2-imagine 2.0.2 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[dev-master, 2.0.x-dev].
- - Removal request for yiisoft/yii2-imagine == 9999999-dev
- - 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].
-
- Potential causes:
- - A typo in the package name
- - The package is not available in a stable-enough version according to your minimum-stability setting
- see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
-
- 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代码
- composer global require "fxp/composer-asset-plugin:1.0.0"
问题解决。
XML/HTML代码
- composer update
- Loading composer repositories with package information
- Updating dependencies (including require-dev)
- Reading bower.json of bower-asset/jquery.inputmask (3.1.47)
- 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
- The credentials will be swapped for an OAuth token stored in /Users/*******/.composer/auth.json, your password will not be stored
- To revoke access to this token you can visit https://github.com/settings/applications
- Username:********
- Password:********
- Token successfully created
- Reading bower.json of bower-asset/jquery.inputmask (3.1.44)
- 。。。。。。。此处省略500字
Tags: yii2
PHP | 评论:2
| 阅读:44055