Home Backend Development PHP Tutorial 从零开始学YII2框架(一)通过Composer安装Yii2框架_php实例

从零开始学YII2框架(一)通过Composer安装Yii2框架_php实例

Jun 07, 2016 pm 05:16 PM
composer Install

最近在学习PHP,着手找一个能快速上手的框架来学习。一开始看兄弟连视频时候讲师推荐ThinkPHP。于是我选择了ThinkPHP来尝试,这个框架的上手难度系数不大,能快速开发一款应用。适合小型的企业应用。因为是国人开发的,中文支持比较好。有比较全面的文档,官网社区也比较活跃。因为我接触的项目都是用Oracle数据库的,所以我想找一款对Oracle支持比较好的PHP框架,但是ThinkPHP框架对Oracle的支持实在是不好。所以我换了Yii框架来试试对Oracle的支持程度。

       Yii框架现在稳定版本是1.1.14。目前2.0是测试版。花了几天时间学习了下Yii1来创建应用。有关Yii的文档不是很多。大多都是原版英文的。但是对Oracle的支持还可以。使用的是AR技术。最近看了下Yii2的文档。它加入了PHP的命名空间概念、加入了Bootstrap、smarty等很多好用的功能。比Yii1进步很大,最后我决定学习Yii2框架。基于对Yii1的了解,Yii2应该更加出色。

今天终于搞明白怎么安装Yii2了。对于我这种小白来说真是费尽周折。下面来介绍下如何安装Composer和如何使用Composer安装Yii2。

Composer是PHP中用来管理依赖(dependency)关系的工具。你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer会帮你安装这些依赖的库文件。

Windows安装Composer:
一、下载Composer

官网下载:https://getcomposer.org/download/

二、开启PHP的openssl支持

修改D:\WAMP\bin\php\php5.4.12配置文件php.ini

去掉注释;


三、安装Composer

一路"next"安装完毕。

安装完毕会提示你重新打开CMD命令行使用。

安装Yii2 - advanced 模板
一、下载yii2 - advanced 模板

官网下载:http://www.yiiframework.com/download/

下载完毕解压至
D:\WAMP\www

二、通过composer安装

打开CMD,跳转到目录
D:\WAMP\www\advanced

我们来生成一个名为“yii2test”的app。

输入命令:

composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced ../yii2test

等待… …出现如下界面,表示安装成功。

1995-1

三、初始化项目

执行CMD命令init

1995-2

测试安装结果

地址栏输入:http://localhost/yii2test/frontend/web/index.php

会看到如下界面:


至此安装Yii2完毕,后续我会跟进关于PHP框架Yii2的学习进度。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Composer's advanced features: aliases, scripts, and conflict resolution Composer's advanced features: aliases, scripts, and conflict resolution Jun 03, 2024 pm 12:37 PM

Composer's advanced features: aliases, scripts, and conflict resolution

Agile development and operation of PHP microservice containerization Agile development and operation of PHP microservice containerization May 08, 2024 pm 02:21 PM

Agile development and operation of PHP microservice containerization

PHP code version control and collaboration PHP code version control and collaboration May 07, 2024 am 08:54 AM

PHP code version control and collaboration

What are the common ways to convert arrays to objects in PHP? What are the common ways to convert arrays to objects in PHP? Apr 28, 2024 pm 10:54 PM

What are the common ways to convert arrays to objects in PHP?

PHP array parallel sorting: taking advantage of multi-core CPUs to improve performance PHP array parallel sorting: taking advantage of multi-core CPUs to improve performance Apr 27, 2024 am 10:03 AM

PHP array parallel sorting: taking advantage of multi-core CPUs to improve performance

How to use PHP CI/CD to iterate quickly? How to use PHP CI/CD to iterate quickly? May 08, 2024 pm 10:15 PM

How to use PHP CI/CD to iterate quickly?

How to use Redis cache in PHP array pagination? How to use Redis cache in PHP array pagination? May 01, 2024 am 10:48 AM

How to use Redis cache in PHP array pagination?

Visualization technology of PHP data structure Visualization technology of PHP data structure May 07, 2024 pm 06:06 PM

Visualization technology of PHP data structure

See all articles