1, here is Win10 installed is Yii2.0, Chinese community: http://www.yiichina.com/.
2, first understand the installation method:
Server is Wamp, the Yii2.0 advanced version of the extracted files into the WWW directory, add php to the Global command (right-click "Computer"-"Properties"-"Advanced system Settings" and then in the System Properties Select "Advanced"-environment variables--Edit System variables-double-click Path-- Add the PHP Environment address setting), run cmd to the WWW root directory:
(1)> php init 选 0 --> 选 yes (2)找到 common/config目录下的main-local.php配置文件,先对数据库进 行配置: ‘db‘ => [
' Class ' = ' yii\db\connection ',
' DSN ' = ' mysql:host=localhost;dbname=blogdeam2db ',
' Username ' = ' root ',
' Password ' = ' 123456789 ',
' CharSet ' = ' utf8 ',
],
(3) Use commands to generate the user-related tables and models built into the Advanced application template (two tables are built in the database):
>php Yii Migrate
Choose Yes
3. Directory resolution
Controllers/Control class
models/Model Class
views/View class
assets/ 资源文件 commands/ 控制台命令类 tests/ 测试文件 config/ 配置文件 web/ 入口文件 index.php 每个应用唯一入口文件 assets js\css资源文件 runtime/ 运行时生成日志缓存文件 vendor/ Yii自身框架及三方扩展 commom/ 为通用文件夹 backend/ 后台应用(包含完整的MVC) frontend/ 前台应用(包含完整MVC) yii(控制台文件执行脚本)
4. MVC Concept and Logic analysis
Each application body has only one entry address, we enter an address to the browser address (for example: Http://localhost/backend/web/index.php?r=site/index, send a corresponding request command to the server, The server then submits the parameter return value based on the address.
Here the Web server executes index.php, and then the portal file does two things:
(1) Read the configuration file web.php;
(2) Instantiate the application body with the loaded configuration data
The application master then controls the entire program's life cycle until the server returns the data to the customer service (returning a page).
The URL that is carried by the application principal resolves the route with the assistance of the request processing build, and the parsing is based on the R value of the index?r= to determine what to do.
The Sitecontroller controller is generated during the parsing process, and then the controller executes the internal Actionindex action (before performing the filter action), typically executing the render () method in the action, loading the database data through models, Put the data in the View template views.
Finally, the view of the data rendering is given to the response processing component, and the component will get the page feedback to the customer service end user.
Introduction to YII Framework Learning (1)--yii Concept and logic analysis of MVC