【注释:】本人原创,如需转载请注明来源链接!

通过安装Composer方式安装Yii

如果还没有安装 Composer,你可以按 getcomposer.org 中的方法安装。 在 Linux 和 Mac OS X 中,你可以运行如下命令:

curl -sS https://getcomposer.org/installer | php

mv composer.phar /usr/local/bin/composer

步骤:

一、打开终端

二、安装composer:

1、终端输入:curl -sS https://getcomposer.org/installer | php

composer安装成功

2、终端输入:mv composer.phar /usr/local/bin/composer

将composer.phar移动到 /usr/local/bin/composer支持全局访问composer命令

3、验证方法:(注意:需要有访问权限,否则会提示没有权限访问)

输入:composer -v

三、安装Yii2

Composer 安装后,切换到一个可通过 Web 访问的目录,执行如下命令即可安装 Yii :

composer global require "fxp/composer-asset-plugin:^1.2.0"

composer create-project --prefer-dist yiisoft/yii2-app-basic basic

第一条命令安装 Composer asset plugin, 它是通过 Composer 管理 bower 和 npm 包所必须的,此命令全局生效,一劳永逸。

第二条命令会将 Yii 安装在名为 basic 的目录中。如果你想使用其它目录名称,你可以选择其他目录名称。

1、终端输入:composer global require "fxp/composer-asset-plugin:^1.2.0"

如果你没有安装Gii该过程会提示你是否安装,安装即可(以下个人项目名称cqy,当然也可以修改成自己想要的项目名称)

2、终端输入:composer create-project --prefer-dist yiisoft/yii2-app-basic cqy

如果出现以下提示:

说明你权限不够,输入:sudo -s,提供root权限

有了权限之后重新输入命令,当进行到一半的时候发现需要token

token命令的话需要Github账号来获取
3、获取token
在使用github获取数据的时候,需要注册一个github账户
在账户 Account -->Setting 点击后页面刷新后, 点击 Personal access tokens, 点击Generate new Token按钮 生成token
获取到token后输入即可继续安装,如下:

Token (hidden):
Token stored successfully.
Package operations: 59 installs, 0 updates, 0 removals
- Installing yiisoft/yii2-composer (2.0.5): Downloading (100%)
- Installing swiftmailer/swiftmailer (v5.4.7): Downloading (100%)
- Installing bower-asset/jquery (2.2.4): Downloading (100%)
- Installing bower-asset/yii2-pjax (v2.0.6): Downloading (100%)
- Installing bower-asset/punycode (v1.3.2): Downloading (100%)
- Installing cebe/markdown (1.1.1): Downloading (100%)
- Installing ezyang/htmlpurifier (v4.9.2): Downloading (100%)
- Installing bower-asset/jquery.inputmask (3.3.5):Downloading (100%) )
- Installing yiisoft/yii2 (2.0.11.2): Downloading (100%)
- Installing yiisoft/yii2-swiftmailer (2.0.6): Downloading (100%)
- Installing bower-asset/bootstrap (v3.3.7): Downloading (100%)
- Installing yiisoft/yii2-bootstrap (2.0.6): Downloading (100%)
- Installing yiisoft/yii2-debug (2.0.9): Downloading (100%)
- Installing bower-asset/typeahead.js (v0.11.1): Downloading (100%)
- Installing phpspec/php-diff (v1.1.0): Downloading (100%)
- Installing yiisoft/yii2-gii (2.0.5): Downloading (100%)
- Installing fzaninotto/faker (v1.6.0): Downloading (100%)
- Installing yiisoft/yii2-faker (2.0.3): Downloading (100%)
- Installing psr/log (1.0.2): Downloading (100%)
- Installing symfony/debug (v3.2.7): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.3.0): Downloading (100%)
- Installing symfony/console (v3.2.7): Downloading (100%)
- Installing stecman/symfony-console-completion (0.7.0): Downloading (100%) - Installing sebastian/diff (1.4.1): Downloading (100%)
- Installing sebastian/recursion-context (2.0.0): Downloading (100%)
- Installing sebastian/exporter (2.0.0): Downloading (100%)
- Installing sebastian/comparator (1.2.4): Downloading (100%)
- Installing behat/gherkin (v4.4.5): Downloading (100%)
- Installing symfony/dom-crawler (v3.2.7): Downloading (100%)
- Installing symfony/css-selector (v3.2.7): Downloading (100%)
- Installing symfony/browser-kit (v3.2.7): Downloading (100%)
- Installing symfony/yaml (v3.2.7): Downloading (100%)
- Installing symfony/event-dispatcher (v3.2.7): Downloading (100%)
- Installing symfony/finder (v3.2.7): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing guzzlehttp/psr7 (1.4.2): Downloading (100%)
- Installing sebastian/version (2.0.1): Downloading (100%)
- Installing sebastian/environment (2.0.0): Downloading (100%)
- Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%) - Installing phpunit/php-token-stream (1.4.11): Downloading (100%)
- Installing phpunit/php-text-template (1.2.1): Downloading (100%)
- Installing phpunit/php-file-iterator (1.4.2): Downloading (100%)
- Installing phpunit/php-code-coverage (4.0.8): Downloading (100%)
- Installing sebastian/resource-operations (1.0.0): Downloading (100%) - Installing sebastian/object-enumerator (2.0.1): Downloading (100%)
- Installing sebastian/global-state (1.1.1): Downloading (100%)
- Installing doctrine/instantiator (1.0.5): Downloading (100%)
- Installing phpunit/phpunit-mock-objects (3.4.3):Downloading (100%) )
- Installing phpunit/php-timer (1.0.9): Downloading (100%)
- Installing webmozart/assert (1.2.0): Downloading (100%)
- Installing phpdocumentor/reflection-common (1.0): Downloading (100%) - Installing phpdocumentor/type-resolver (0.2.1): Downloading (100%)
- Installing phpdocumentor/reflection-docblock (3.1.1): Downloading (100%) - Installing phpspec/prophecy (v1.7.0): Downloading (100%)
- Installing myclabs/deep-copy (1.6.1): Downloading (100%)
- Installing phpunit/phpunit (5.7.19): Downloading (100%)
- Installing codeception/base (2.2.10): Downloading (100%)
- Installing codeception/verify (0.3.3): Downloading (100%)
- Installing codeception/specify (0.4.6): Downloading (100%)
symfony/console suggests installing symfony/filesystem ()
symfony/console suggests installing symfony/process ()
symfony/browser-kit suggests installing symfony/process ()
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/event-dispatcher suggests installing symfony/http-kernel ()
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.1)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
codeception/base suggests installing flow/jsonpath (For using JSONPath in REST module)
codeception/base suggests installing phpseclib/phpseclib (for SFTP option in FTP Module)
codeception/base suggests installing league/factory-muffin (For DataFactory module)
codeception/base suggests installing league/factory-muffin-faker (For Faker support in DataFactory module)
codeception/base suggests installing symfony/phpunit-bridge (For phpunit-bridge support)
Writing lock file
Generating autoload files
> yii\composer\Installer::postCreateProject
chmod('runtime', 0777)...done.
chmod('web/assets', 0777)...done.
chmod('yii', 0755)...done.
安装成功!

Mac安装composer安装Yii2项目的更多相关文章

  1. window下安装composer and yii2

    我的环境是集合包xampp 1,下载composer:下载地址https://getcomposer.org/download/, 点击蓝色字体“Composer-Setup.exe” 2,安装com ...

  2. 我的CentOS6.5下及windows7下 安装composer与Yii2的过程

    用yii2以来,安装composer老是不成功,所以一直在windows下的php里,用直接解压的方法运行yii2. 后来越来越多的场合,需要用composer,终于下决心,要在Linux下搞掂它! ...

  3. MacBook Pro 安装composer及Yii2.0

    最近想看看Yii的一些东西,需要安装一下composer curl -sS https://getcomposer.org/installer | php 此操作会下载最新版本到当前的目录下 然后将下 ...

  4. composer.json:项目安装!!!!!!!!!!

    基本用法 基本用法 安装 composer.json:项目安装 关于 require Key 包名称 包版本 下一个重要版本(波浪号运算符) 稳定性 安装依赖包 composer.lock - 锁文件 ...

  5. composer安装学习

    Packagist 镜像 网站地址 http://www.phpcomposer.com/ 请各位使用本镜像的同学注意: 本镜像已经依照 composer 官方的数据源安全策略完全升级并支持 http ...

  6. Win7下安装composer, 并使用其安装smarty

    安装composer需要开启PHP openssl扩展. 1) 先查看PHP是否开启了openssl扩展 键盘win+r 输出cmd, 可以看到Dos窗口, 然后执行php -m (需要添加PHP环境 ...

  7. Linux rabbitmq的安装和安装amqp的php插件

    RabbitMQ是一个消息代理.它的核心原理非常简单:接收和发送消息.你可以把它想像成一个邮局:你把信件放入邮箱,邮递员就会把信件投递到你的收件人处.在这个比喻中,RabbitMQ是一个邮箱.邮局.邮 ...

  8. MAC中Composer的使用

    安装composer 安装前需确保系统PHP版本在5.3以上,在终端中执行以下命令下载Composer可执行文件: curl -sS https://getcomposer.org/installer ...

  9. 安装 composer 并启动 yii2 项目

    环境 MacOS 10.12.6 PHP 5.6.30 yii2.0 一.composer (类似 node's npm) 1.安装 php -r "copy('https://getcom ...

随机推荐

  1. xBIM 实战04 在WinForm窗体中实现IFC模型的加载与浏览

    系列目录    [已更新最新开发文章,点击查看详细]  WPF底层使用 DirectX 进行图形渲染.DirectX  能理解可由显卡直接渲染的高层元素,如纹理和渐变,所以 DirectX 效率更高. ...

  2. C#--DataGridView添加DateTimePicker时间控件

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  3. 人生苦短,请用 Chrome!

    在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...

  4. 百度编辑器UEditor修改成支持物理路径

    一.前言 我虽然工作了2年.有快1年没有做后台的开发了.最近要写个新项目用到富文本编辑器,然后选择用了百度的UEditor.在使用过程中感觉有些不太好.然后就自己手动改一下源码,写得不好请见谅.这只是 ...

  5. Apache Ignite - 轉

    Ignite Docs Online: ignite-doc-cn https://dongwq.gitbooks.io/ignite-doc/content/index.html - Apache ...

  6. 使用Java开发高性能网站需要关注的那些事儿2

      近期各家IT媒体举办的业内技术大会让很多网站都在披露自己的技术内幕与同行们分享,大到facebook,百度,小到刚起步的网站.facebook,百度之类的大型网站采用的技术和超凡的处理能力的确给人 ...

  7. PyQuery使用

    PyQuery库是一个非常强大的网页解析库,如果你有前端开发经验的,都应该接触过jQuery,那么PyQuery就是你非常绝佳的选择,PyQuery 是 Python 仿照 jQuery 的严格实现. ...

  8. str 数据类型的用法

    ---------------------------------------------------------------------------------------------------- ...

  9. HDU-2896 病毒侵袭 字符串问题 AC自动机

    题目链接:https://cn.vjudge.net/problem/HDU-2896 题意 中文题 给一些关键词和一个字符串,问字符串里包括了那几种关键词 思路 直接套模版 改insert方法,维护 ...

  10. POJ 3093 Margaritas on the River Walk(背包)

    题意 n个有体积的物品,问选取一些物品,且不能再继续选有多少方法? n<=1000 题解 以前的考试题.当时是A了,但发现是数据水,POJ上WA了. 把体积从小到大排序枚举没选的物品中体积最小的 ...