The operation principle and ThinkPHP5.0

Directory Structure:

Operating principle:

(1) mvc design pattern
m model
v View
c Controller
Principle: M c acquisition schedule data, loading the data view to the client
(2) engine technology template (template TP5 built engine, not Smarty)
(. 3) named space

 namespace app\admin\controller;

app application
admin module
controller controller
TP5 in the file path and file name space where the same directory path

Access format in the absence of open routes:
//localhost/tp5/public/index.php/index/Index/index: HTTP
index.php file entry
module in the application index
controller module in the Index
under the index controller method


url visit:
 do not support the common mode http://www.tp5.com/index.php?m=index&c=Index&a=add
 only supports pathinfo mode http://www.tp5.com/index.php/index/Index ? / the Add name = Junge
 pathinfo modes: streamlined url address, you can improve your site's ranking included, in favor of seo optimized

open error debugging:
       the application / config.php 
   // application in debug mode
    'app_debug' => to true,
    // application Trace
    ' app_trace '=> true, 
routing
(1) commonly used:
the route :: rule (' routing rule ',' module / controller / method ',' request mode ', [pseudo-static setting], [type parameter settings]);
such as: Route :: rule ( '/ admin /: id', 'admin / index / index', 'get', [ 'ext' => 'html'], [ 'id' => '\ d +']) ;
(2) route requests embodiment
route :: get ( "routing rules," "module / controller / method");
Format:
the Route :: GET ( "/ Test", "index / Index / index");
(. 3) implicit routing
All the all access operations to the same routing rule (/ Test) processing 
Route :: controller ( "Routing Rules," "module / controller");
Format:
Route :: controller ( "/ Test", "index / Index ");
(. 4) routes an alias
by all methods in the routing alias access controller
route :: alias (" alias "" module / controller ");
format:
route :: alias (" Users "," ADMIN / Test ");

Published 172 original articles · won praise 45 · views 40000 +

Guess you like

Origin blog.csdn.net/fish_study_csdn/article/details/104498147