Introduction to ThinkPHP5 quick start method. Download
Download address: http://www.thinkphp.cn/
This time using thinkphp5, I used github to install it.
Github
Application project: https://github.com/top-think/think
Core framework: https://github.com/top-think/framework
In addition:
Code Cloud:
Application project: https://git.oschina.net/liuIntroduction to ThinkPHP5 quick start methodIntroduction to ThinkPHP5 quick start methodst/thinkphp5.git
Core framework: https://git.oschina.net/liuIntroduction to ThinkPHP5 quick start methodIntroduction to ThinkPHP5 quick start methodst/ framework.git
Coding:
Application project: https://git.coding.net/liuIntroduction to ThinkPHP5 quick start methodIntroduction to ThinkPHP5 quick start methodst/thinkphp5.git
Core framework: https://git.coding.net/liuIntroduction to ThinkPHP5 quick start methodIntroduction to ThinkPHP5 quick start methodst/framework.git
Downloaded directory:
tp5 ├─application 应用目录 ├─extend 扩展类库目录(可定义) ├─public 网站对外访问目录 ├─runtime 运行时目录(可定义) ├─vendor 第三方类库目录(Composer) ├─thinkphp 框架核心目录 ├─build.php 自动生成定义文件(参考) ├─composer.json Composer定义文件 ├─LICENSE.txt 授权说明文件 ├─README.md README 文件 ├─think 命令行工具入口
The structure of the core framework directory is as follows:
├─thinkphp 框架系统目录 │ ├─lang 语言包目录 │ ├─library 框架核心类库目录 │ │ ├─think think 类库包目录 │ │ └─traits 系统 traits 目录 │ ├─tpl 系统模板目录 │ │ │ ├─.htaccess 用于 apache 的重写 │ ├─.travis.yml CI 定义文件 │ ├─base.php 框架基础文件 │ ├─composer.json composer 定义文件 │ ├─console.php 控制台入口文件 │ ├─convention.php 惯例配置文件 │ ├─helper.php 助手函数文件(可选) │ ├─LICENSE.txt 授权说明文件 │ ├─phpunit.xml 单元测试配置文件 │ ├─README.md README 文件 │ └─start.php 框架引导文件
I use It is the apacheIntroduction to ThinkPHP5 quick start method server that comes with kali. Useservice apacheIntroduction to ThinkPHP5 quick start method start
to start. You need to put the entire project downloaded from git into the server running directory. The default for Linux is:
/var/www/html
and then on the browser side Enter:http://localhost/tp5/public/
You will see the welcome page:
If you don’t want to install any WEB server, you can also directly use the WebServer that comes with PHP and run router.php to run the test.
Enter the command line, enter the tp5/public directory, and enter the following command:
php -S localhost:8888 router.php
You can then directly access
http://localhost:8888
├─application 应用目录(可设置) │ ├─index 模块目录(可更改) │ │ ├─config.php 模块配置文件 │ │ ├─common.php 模块公共文件 │ │ ├─controller 控制器目录 │ │ ├─model 模型目录 │ │ └─view 视图目录 │ │ │ ├─command.php 命令行工具配置文件 │ ├─common.php 应用公共文件 │ ├─config.php 应用配置文件 │ ├─tags.php 应用行为扩展定义文件 │ ├─database.php 数据库配置文件 │ └─route.php 路由配置文件
php think build --module demo
├─demo │ ├─controller 控制器目录 │ ├─model 模型目录 │ ├─view 视图目录 │ ├─config.php 模块配置文件 │ └─common.php 模块公共文件 同时也会生成一个默认的 Index 控制器文件。
Located at
application/index/controller/Index.phpthere is a default Index class:
Originally it returned the start page, but now it returns hello world.
Copy after login
assign(Introduction to ThinkPHP5 quick start method9;nameIntroduction to ThinkPHP5 quick start method9;,$name); return $this->fetch(); } }
thinkphph uses template rendering. The template is stored in the View folder. There is no View folder by default. We create it ourselves:
Create a view directory under the
application/indexdirectory, create an index directory under the view directory, and then add the template file hello.html, the entire path:
view/index/hello.html
http://localhost/tp5/public/More advanced ones can configure URL routing.
create table if not exists think_data( id int(8) not null auto_increment primary key, data varchar(Introduction to ThinkPHP5 quick start method55) not null )engine=MyISAM default charset=utf8;
Then configure it under
application/database.php:
return [ // 数据库类型 Introduction to ThinkPHP5 quick start method9;typeIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;mysqlIntroduction to ThinkPHP5 quick start method9;, // 服务器地址 Introduction to ThinkPHP5 quick start method9;hostnameIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;Introduction to ThinkPHP5 quick start methodIntroduction to ThinkPHP5 quick start method7.0.0.Introduction to ThinkPHP5 quick start methodIntroduction to ThinkPHP5 quick start method9;, // 数据库名 Introduction to ThinkPHP5 quick start method9;databaseIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;testIntroduction to ThinkPHP5 quick start method9;, // 用户名 Introduction to ThinkPHP5 quick start method9;usernameIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;rootIntroduction to ThinkPHP5 quick start method9;, // 密码 Introduction to ThinkPHP5 quick start method9;passwordIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;Introduction to ThinkPHP5 quick start method9;, // 端口 Introduction to ThinkPHP5 quick start method9;hostportIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;Introduction to ThinkPHP5 quick start method9;, // 连接dsn Introduction to ThinkPHP5 quick start method9;dsnIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;Introduction to ThinkPHP5 quick start method9;, // 数据库连接参数 Introduction to ThinkPHP5 quick start method9;paramsIntroduction to ThinkPHP5 quick start method9; => [], // 数据库编码默认采用utf8 Introduction to ThinkPHP5 quick start method9;charsetIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;utf8Introduction to ThinkPHP5 quick start method9;, // 数据库表前缀 Introduction to ThinkPHP5 quick start method9;prefixIntroduction to ThinkPHP5 quick start method9; => Introduction to ThinkPHP5 quick start method9;think_Introduction to ThinkPHP5 quick start method9;, // 数据库调试模式 Introduction to ThinkPHP5 quick start method9;debugIntroduction to ThinkPHP5 quick start method9; => true,
assign(Introduction to ThinkPHP5 quick start method9;nameIntroduction to ThinkPHP5 quick start method9;,$name); return $this->fetch(); } public function dbtest() { $data = Db::name(Introduction to ThinkPHP5 quick start method9;dataIntroduction to ThinkPHP5 quick start method9;)->find(); $this->assign(Introduction to ThinkPHP5 quick start method9;resultIntroduction to ThinkPHP5 quick start method9;,$data); return $this->fetch(); } }
http://localhost/tp5/public/index.php/index/index/dbtest.
Introduction to the steps for using ThinkPHP
Explain the relevant knowledge of update lock (U) and exclusive lock (X)
The above is the detailed content of Introduction to ThinkPHP5 quick start method. For more information, please follow other related articles on the PHP Chinese website!