Home > Article > Backend Development > Android programmers learn PHP development (34)-ThinkPHP5.0 (6) automatically generated-PhpStorm
The time to witness the miracle has arrived, we have to automatically generate the directory structure~This is the convenience brought by TP~Otherwise we have to use a framework instead of native~
Online documentation: http:// www.kancloud.cn/manual/thinkphp5/118021
which is not convenient for demonstration. If you are interested, please take a look at the development manual~
##We are here.\ Build.php, like this:
// 定义demo模块的自动生成 (按照实际定义的文件名生成) 'demo' => [ '__file__' => ['common.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'], 'controller' => ['Index', 'Test', 'UserType'], 'model' => ['User', 'UserType'], 'view' => ['index/index'], ],
Or, like this:
// 定义index模块的自动生成 'index' => [ '__file__' => ['tags.php', 'user.php', 'hello.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'], 'controller' => ['Index', 'Test', 'UserType'], 'model' => [], 'view' => ['index/index'], ], // 定义test模块的自动生成 'test'=>[ '__dir__' => ['behavior','controller','model','widget'], 'controller'=> ['Index','Test','UserType'], 'model' => ['User','UserType'], 'view' => ['index/index','index/test'], ],
code, specify the directory structure, and automatically generate files.
Look at the picture below: How to automatically generate a custom directory introduction in the entry file:
##index.html:
##
<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2016 http://www.php.cn/ All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.php.cn/ ) // +---------------------------------------------------------------------- // | Author: liu21st <liu21st@gmail.com> // +---------------------------------------------------------------------- // [ 应用入口文件 ] // 定义应用目录 define('APP_PATH', __DIR__ . '/../application/'); // 加载框架引导文件 require __DIR__ . '/../thinkphp/start.php'; /** * 自动生成目录结构 方法1 */ // 读取自动生成定义文件 $build = include '../build.php'; // 运行自动生成 \think\Build::run($build); /** * 自动生成目录结构 方法2 */ //\think\Build::module('admin');
3. Automatically generate the default directory structure and files:
index.html:<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://www.php.cn/ All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.php.cn/ )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
// 定义应用目录
define('APP_PATH', __DIR__ . '/../application/');
// 加载框架引导文件
require __DIR__ . '/../thinkphp/start.php';
/**
* 自动生成目录结构 方法1
*/
//// 读取自动生成定义文件
//$build = include '../build.php';
//// 运行自动生成
//\think\Build::run($build);
/**
* 自动生成目录结构 方法2
*/
\think\Build::module('admin');
Note that in this method, build.php does not need to be operated
The above is the content of Android programmers learning PHP development (34) - ThinkPHP5.0 (6) automatically generates - PhpStorm. For more related content, please pay attention to the PHP Chinese website (www.php .cn)!