Yii2开发环境搭建

标签(空格分隔): Yii2


1 安装 Composer

[ahcj@localhost ~]$ curl -sS https://getcomposer.org/installer | php
[ahcj@localhost ~]$ mv composer.phar /usr/local/bin/composer

2 安装资源管理插件 Composer asset plugin

Composer asset plugin 是通过 Composer 管理 bower 和 npm 包所必须的,此命令全局生效

[ahcj@localhost ~]$ composer global require "fxp/composer-asset-plugin:^1.2.0"

3 安装应用和模板

注意: 在安装过程中 Composer 可能会询问你 GitHub 账户的认证信息,因为可能在使用中超过了 GitHub API (对匿名用户的)使用限制。

# 切换到 www 目录
[ahcj@localhost ~]$ cd www

# 安装基本应用模板
[ahcj@localhost www]$ composer create-project --prefer-dist yiisoft/yii2-app-basic basic

# or
#安装 Yii 的最新开发版
[ahcj@localhost www]$ composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic-dev

4 高级模板(可选)


# 开发复杂应用时安装高级模板
[ahcj@localhost www]$ composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-advanced

5 使用内置服务器启动

# 切换到程序所在目录
[ahcj@localhost ~]$ cd basic

# 启动内置 server
[ahcj@localhost basic]$ ./yii serve
Server started on http://localhost:8080/
Document root is "/home/ahcj/www/basic/web"
Quit the server with CTRL-C or COMMAND-C.

接下来就可以使用 http://localhost:8080/ 访问应用了。 如果没有看到页面,运行自检程序检查

[ahcj@localhost basic]$ php requirements.php 

此处输入图片的描述

6 内置服务器功能

语法

./yii serve [address] [options]

address 可选,可以指定访问的网址(ip),不写的话使用默认值localhost:8080。

PS

./yii serve  mysite.com

#or
./yii serve  192.168.1.25:8081

帮助

[ahcj@localhost basic]$ ./yii serve -h

DESCRIPTION

Runs PHP built-in web server


USAGE

yii serve [address] [...options...]

- address: string (defaults to 'localhost')
  address to serve on. Either "host" or "host:port".


OPTIONS

--appconfig: string
  custom application configuration file path.
  If not set, default application configuration is used.

--color: boolean, 0 or 1
  whether to enable ANSI color in the output.
  If not set, ANSI color will only be enabled for terminals that support it.

--docroot, -t: string (defaults to '@app/web')
  path or [path alias](guide:concept-aliases) to directory to serve

--help, -h: boolean, 0 or 1
  whether to display help information about current command.

--interactive: boolean, 0 or 1 (defaults to 1)
  whether to run the command interactively.

--port, -p: int (defaults to 8080)
  port to serve on.

--router, -r: string
  path to router script.
  See https://secure.php.net/manual/en/features.commandline.webserver.php
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,923评论 18 139
  • Sites 网站 yiifeed:Yii 最新动态都在这里 yiigist:Yii 专用的 Packages my...
    guanguans阅读 2,664评论 0 11
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,953评论 6 342
  • 安装Yii2 你可以通过两种方式来安装Yii框架: 通过Composer安装 通过下载一个所需文件以及Yii框架文...
    伊Summer阅读 767评论 0 0
  • 把生活当成一面镜子,去谦逊的生活。
    不可知相遇阅读 118评论 0 0