composer应用

ubentu安装

进入自己的项目根目录
cd/path/to/my/project

下载composer

curl -s http://getcomposer.org/installer

把这个文件移到bin目录下,它允许你简化命令

sudo mv composer.phar /usr/bin/composer

查看composer相关信息

composer about 

windows安装

进入composer官网,点下载

http://www.phpcomposer.com/

会得到一个二进制文件:composer-setup.exe

双击运行该文件,安装过程中找到php目录下php.exe文件才能安装成功

运行CMD,进入项目根目录,复制一份composer.json文件过来

在composer.json文件中加入:

 

进入项目根目录,例如:

cd D:\WWW\importArea

D:

注意:以后下载依赖包都要用require命令

composer require crazyfd/yii2-qiniu dev-master

第三步 安装YII2

命令行下切换到一个php可以访问的站点目录

然后执行命令(注意php可执行文件路径和 composer路径修改成你自己的安装路径):
如下命令将Yii2.0.0版本安装在名为 yii2 的目录中,具体目录名可以根据自己的需要修改:
/usr/local/php/bin/php /usr/local/bin/composer create-project yiisoft/yii2-app-basic yii2 2.0.0
需要耐心等待,安装过程中可能会出现如下信息要求你输入用户名 和密码(自己到YII官网"https://github.com/"注册一个账户,把账户密码填进去就OK了):
如果遇到如下认证提示信息请点击下面https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+localhost.localdomain+2015-05-14+1600语句登录Git网站,然后生成一个类似 的认证秘钥复制粘贴到Token(hidden)处回车即可:
Could not fetch https://api.github.com/repos/RobinHerbots/jquery.inputmask/contents/bower.json?ref=f44d5deec804c72fe85da31819b18bdcdad26f65, please create a GitHub OAuth token to Go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+localhost.localdomain+2015-05-14+1600
to retrieve a token. It will be stored in "/root/.composer/auth.json" for future use by Composer.
Token (hidden):输入在官网生成的秘钥回车即可


Installing yiisoft/yii2-app-basic (2.0.0)
  - Installing yiisoft/yii2-app-basic (2.0.0)
    Downloading: 100%         

Created project in yii2
Loading composer repositories with package information
Installing dependencies (including require-dev)
Reading bower.json of bower-asset/jQuery.inputmask (3.1.29)
Could not fetch https://api.github.com/repos/RobinHerbots/jquery.inputmask/contents/bower.json?ref=faf19625822fbd54765d26baac3154cd132769d1, enter your GitHub credentials to go over the API rate limit
The credentials will be swapped for an OAuth token stored in /root/.composer/auth.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username:myyiiname (这里填写你在官网注册的账户名)
Password:myyiipwd (密码,你懂得)
输入账户密码后会出现如下认证成功的提示(如果没有就证明你的账户密码错了,或者你刚在YII官网注册的新账户没有通过邮件激活):
Token successfully created

认证通过的提示信息下面紧跟着一句如下的进度提示信息,说明正在安装过程中,需要你耐心等待,后面的小数点会随着安装进度有微妙的变化,
Reading bower.json of bower-asset/typeahead.js (v0.10.0)

 

下载好类库文件后,在入口文件index.php中

添加 require('vendor/autoload.php');

需要用这些类的话直接 new就可以了,例如:

new phpQuery()

 

posted @ 2016-09-30 16:50  星希望  阅读(253)  评论(0编辑  收藏  举报