I. Download and installation of TP framework
TP frame Download URL: http://www.thinkphp.cn/
Create a directory tpshop directory under the WWW directory of Wamp
1. After compressing the downloaded package, copy all the files in the package to the root directory (tpshop) of the created project
| Application
| Public
| thinkphp
|. Htaccess
|composer.json
|index.php
| Readme.md
2.index.php is the entry file for the project we're creating.
Detecting PHP environments
if (Version_compare (php_version, ' 5.3.0 ', ' < ') die (' Require PHP > 5.3.0! ');
Open Debug mode suggest the development phase to open the deployment phase comment or set to False
Define (' App_debug ', True);
Define the project name
Define (' App_name ', ' APP ');
Defining Project Paths
Define (' App_path ', './application/');
Introducing the thinkphp entry file
Require './thinkphp/thinkphp.php ';
3. Access Localhost/tpshop/index.php/app/index/index The project is now created
Common Project common file directory common functions for placing items
Conf the configuration directory for the project to place all the configuration files
Lib Project Class Library Directory includes action and model subdirectories
Template Catalog Support Template topic for TPL projects
Extended directory of the Extend framework
4. Error log Location
Runtime/logs/cache Compiling the Directory
5.Tp Access Address Parameters
HTTP://LOCALHOST/TPSHOP/INDEX.PHP/APP/INDEX/INDEX/10;
6. Template tag configuration and database configuration! The template tag is {} By default, or it can be changed, in the configuration file
Return Array (
/************** delimiter ***********/
' Tmp_l_delim ' = ' <{',
' Tmp_r_delim ' = '}> ',
/**********************/
' Db_type ' = ', '//database type
' Db_host ' = ' + ',//server address
' Db_name ' = ', '//database name
' Db_user ' + ', '//user name
' Db_pwd ' and ' = ',//password
' Db_port ' = ', '//Port
' Db_prefix ' = ', '//database table prefix
' Db_params ' = = Array (),//database connection parameters
' Db_debug ' + TRUE,//Database debug mode can log SQL logs after opening
' Db_fields_cache ' = = true,//enable field caching
' Db_charset ' = ' utf8 ',//
);
7.__ROOT__ output is the project root directory;/tpshop
__app__ the path to the current project/tpshop/index.php
__URL__ the current project's module/tpshop/index.php/index
__action__ the URL address of the current project's/tpshop/index.php/index/index
__PUBLIC__ will be replaced with the public directory of the current project
__SELF__ will replace the current URL
Note: Static resources in TP must be the absolute path of the site
8.Thinkphp supports four URL modes
① Normal Mode
http://localhost/test/index.php?m=Index&a=index&id=10
Get module and method names
Module_name
Action_name
②pathinfo mode
HTTP://LAOCALHOST/TEST/INDEX.PHP/INDEX/INDEX/ID/10;
③rewrite mode
HTTP://LOCALHOST/TEST/INDEX/INDEX/ID/10;
Make sure to modify the Apache configuration file using the rewrite mode
1) Open LoadModule rewrite_module modules/mod_write.so
2) Modify the site root directory to support rewrite address rewriting
<directory "C://appserv/www" >
Options Indexs Folloewsymlinks
#一定要把multivews去掉
AllowOverride All
Order Allow,deny
Allow from all
</Directory>
3) Restart Apache
4) Place the. htaccess in the directory of the portal file:
<ifmodule mod_rewrite.c>
Options +followsymlinks
Rewriteengine on
Rewritecond%{request_filename}!-d
Rewritecond%{request_filename}!-f
Rewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]
</IfModule>
④ compatibility mode
HTTP://LOCALHOST/TEST/?S=/INDEX.INDEX/ID/10;
9. Default Access modules and methods in configuration
' Defult_module ' = ' Index '//default module name
' Default_action ' = ' index '//Default action method
10 Read Configuration
C (' parameter name '); Gets the parameter value of the setting in config
11. Display template $this->display (); Assigning variables to templates: $this->assign (' data ', $data);
The module address jumps $this->success (' OK ', ' index ');
Jump across modules: $this->success (' Add Success ', U (' Login/index '));
REDIRECT $this->redirect ();
12 support for multi-function filtering
"Default_filier" = "trim,htmlspecialchars,strip_tags";
Summary of TP framework overall study (I.)