PHP -- Yii 框架之快速建立web应用骨架
Basically, Yii(读音: 易, Yes it is的缩写)是个高性能PHP框架, 用来开发web 2.0应用。 用官网的话说叫快速, 安全, 专业。
在开始之前, 环境需要准备好。 具体点, 需要安装PHP。 为了能开发基于DB的web应用, MySQL也需要安装。 我的本地环境安装了EasyPHP5.3(包含了web服务器, PHP, MySQL)。 同时本地也安装有独立的PHP5.4。 具体环境搭建一搜索一堆, 这里略过。
要想快速建立一个web应用, 只需执行一个命令:
以下是命令输出信息:
Create a Web application under 'C:\Progs\EasyPHP-5.3.9\www\testdrive'? (yes|no) [no]:y
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/assets
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/css
generate css/bg.gif
generate css/form.css
generate css/ie.css
generate css/main.css
generate css/print.css
generate css/screen.css
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/images
generate index-test.php
generate index.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected
generate protected/.htaccess
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/commands
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/commands/shell
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/components
generate protected/components/Controller.php
generate protected/components/UserIdentity.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/config
generate protected/config/console.php
generate protected/config/main.php
generate protected/config/test.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/controllers
generate protected/controllers/SiteController.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/data
generate protected/data/schema.mysql.sql
generate protected/data/schema.sqlite.sql
generate protected/data/testdrive.db
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/extensions
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/messages
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/migrations
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/models
generate protected/models/ContactForm.php
generate protected/models/LoginForm.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/runtime
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests
generate protected/tests/bootstrap.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests/fixtures
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests/functional
generate protected/tests/functional/SiteTest.php
generate protected/tests/phpunit.xml
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests/report
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests/unit
generate protected/tests/WebTestCase.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/views
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/views/layouts
generate protected/views/layouts/column1.php
generate protected/views/layouts/column2.php
generate protected/views/layouts/main.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/views/site
generate protected/views/site/contact.php
generate protected/views/site/error.php
generate protected/views/site/index.php
generate protected/views/site/login.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/views/site/pages
generate protected/views/site/pages/about.php
generate protected/yiic
generate protected/yiic.bat
generate protected/yiic.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic/views
generate themes/classic/views/.htaccess
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic/views/layouts
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic/views/site
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic/views/system
Your application has been created successfully under C:\Progs\EasyPHP-5.3.9\www\testdrive.
其实到这里, 应用已经建立完了。 下面启动EasyPHP测试刚刚建立的应用, 看看是神马样子滴
猛然间让我想起来Rails框架, 也是一个命令一个应用就出来了。 第一感觉凉爽.. 有继续下去的勇气了, 嘿嘿。 看看除了Home页面还生成了啥:
Contact Login也有:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.
