It's time to witness the miracle. we have to automatically generate the directory structure ~ This is the convenience of TP ~ Otherwise, we will use the framework instead of the native ~ It's time to witness the miracle. we have to automatically generate the directory structure ~ This is the convenience of TP ~ Otherwise, we will use the framework instead of the native ~
Online Documentation: http://www.kancloud.cn/manual/thinkphp5/118021
1. command line automatic generation
It is not convenient for demonstration. if you are interested, read the Development Manual ~
2. add automatically generated code
We add in. \ build. php as follows:
// Define the automatic generation of the demo module (based on the actual file name) 'demo' => ['_ file _' => ['common. php '],' _ dir _ '=> ['behavior', 'controller', 'model', 'View'], 'controller' => ['index', 'test', 'usertype'], 'model' => ['user', 'usertype'], 'View' => ['index/index'],],
Or, like this:
// Define the automatic generation of the index module 'index' => ['_ file _' => ['tags. php', 'user. php', 'Hello. php '],' _ dir _ '=> ['behavior', 'controller', 'model', 'View'], 'controller' => ['index', 'test', 'usertype'], 'model' => [], 'View' => ['index/index'],], // define the automatic generation of the test module 'test' => ['_ dir _' => ['behavior ', 'controller', 'model ', 'https'], 'controller' => ['index', 'test', 'usertype'], 'model' => ['user', 'usertype'], 'View' => ['index/Index', 'index/test'],],
Code, specify the directory structure, and automatically generate files.
View: The description of the custom directory automatically generated in the entry file:
Index.html:
// + ---------------------------------------------------------------------- // [Application portal file] // define the application directory define ('app _ path', _ DIR __. '/.. /application/'); // load the framework boot file require _ DIR __. '/.. /thinkphp/start. php ';/*** method for automatically generating the directory structure 1 * // read the automatically generated definition file $ build = include '.. /build. php '; // run the automatic generation \ think \ Build: run ($ build);/*** method of automatically generating the directory structure 2 * // \ think \ Build :: module ('admin ');
3. automatically generate the default directory structure and File:
Index.html:
// + ---------------------------------------------------------------------- // [Application portal file] // define the application directory define ('app _ path', _ DIR __. '/.. /application/'); // load the framework boot file require _ DIR __. '/.. /thinkphp/start. php ';/*** method for automatically generating the directory structure 1 * //// read the automatically generated definition file // $ build = include '.. /build. php '; // run automatically generated // \ think \ Build: run ($ build ); /*** method for automatically generating the directory structure 2 */\ think \ Build: module ('admin ');
Note that you do not need to operate build. php in this method.