一:采用Thinkphp5.0框架
Thinkphp5.0简介:
官网下载 和 composer(php依赖管理工具)安装。
目录结构:
application是应用目录,
index目录是模块目录:
模块目录下可以有控制器controller目录控制器直接命名Index.php这里和thinkphp3(IndexController.class.php)不一样了。
也可以在模块下创建model,view目录。
command.php是命令行工具配置。
common.php是公共函数。
config.php是应用公共函数前台可以直接调用。
database.php是数据库的配置文件。
route.php url路由配置文件。
tags.php 应用行为扩展配置文件。
extend目录:
扩展的类库
public目录:
对外部访问的目录
static目录下放的是静态资源(js,css,image)。
index.php文件是项目的入口文件。
router.php文件是快速测试文件。
runtime目录:
运行时候生成的文件。
vendor目录:
第三方类库
thinkphp目录:
thinkphp5核心类库目录。
build.php文件:
定义的自动生成定位文件。
think文件:
命令入口设置文件。
TP5神器-webserver
config.php里面设置
'default_return_type' => 'html',这样就能控制前台输出模式类型。
虚拟域名配置:
也可以使用集成工具配置phpstudy等方面的。
TP5自动化模块搭建
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
return [
// 生成应用公共文件
'__file__' => ['common.php', 'config.php', 'database.php'],
// 定义demo模块的自动生成 (按照实际定义的文件名生成)
/* 'demo' => [
'__file__' => ['common.php'],
'__dir__' => ['behavior', 'controller', 'model', 'view'],
'controller' => ['Index', 'Test', 'UserType'],
'model' => ['User', 'UserType'],
'view' => ['index/index'],
], */
// 其他更多的模块定义
'common' =>[
'__dir__' => ['model'],
'model' => ['Category', 'Admin'],
],
];
1.在app目录下创建了build.php文件
2.命令行切换到站点根目录下
3.使用命令 php think build
编写config.php配置文件修改静态文件路径。
view里面的页面如果存在公共部分的页面,应该放在一个目录里面作为公共使用。需要的页面只需要导入就可以了。
{include file="public/head,public/nav"} 这里和thinkphp3不太一样。<>变 { }。
url访问模式http://localhost/thinkphp5.0/index.php?s=index/user/register
http://localhost/thinkphp5.0/index.php/index/user/register 一样效果
s是模块,后面是控制器,然后方法如果页面的链接可以写成{:url('user/register')};tp5新特性
需求分析:
三大模块 商家模块:
主平台模块:
前台模块:
数据库设计:
数据表:
#生活分类表
CREATE TABLE o2o_category(
id int(11) unsigned NOT NULL auto_increment,
name VARCHAR(50) NOT NULL DEFAULT '',
parent_id int(10) unsigned NOT NULL DEFAULT 0,
listorder int(8) unsigned NOT NULL DEFAULT 0,
status tinyint(1) NOT NULL DEFAULT 0,
create_time int(11) unsigned NOT NULL DEFAULT 0,
update_time int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY parent_id(parent_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
#城市表
CREATE TABLE o2o_city(
id int(11) unsigned NOT NULL auto_increment,
name VARCHAR(50) NOT NULL DEFAULT '',
uname VARCHAR(50) NOT NULL DEFAULT '',
parent_id int(10) unsigned NOT NULL DEFAULT 0,
listorder int(8) unsigned NOT NULL DEFAULT 0,
status tinyint(1) NOT NULL DEFAULT 0,
create_time int(11) unsigned NOT NULL DEFAULT 0,
update_time int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY parent_id(parent_id),
UNIQUE KEY uname(uname)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
#商圈表
CREATE TABLE o2o_area(
id int(11) unsigned NOT NULL auto_increment,
name VARCHAR(50) NOT NULL DEFAULT '',
city_id int(11) unsigned NOT NULL DEFAULT 0,
parent_id int(10) unsigned NOT NULL DEFAULT 0,
listorder int(8) unsigned NOT NULL DEFAULT 0,
status tinyint(1) NOT NULL DEFAULT 0,
create_time int(11) unsigned NOT NULL DEFAULT 0,
update_time int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY parent_id(parent_id),
KEY city_id(city_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
#商户表
CREATE TABLE o2o_bis(
id int(11) unsigned NOT NULL auto_increment,
name VARCHAR(50) NOT NULL DEFAULT '',
email VARCHAR(50) NOT NULL DEFAULT '',
logo VARCHAR(255) NOT NULL DEFAULT '',
licence_logo VARCHAR(255) NOT NULL DEFAULT '',
description text NOT NULL,
city_id int(11) unsigned NOT NULL DEFAULT 0,
city_path varchar(50) NOT NULL DEFAULT '',
bank_info varchar(50) NOT NULL DEFAULT '',
money decimal(20,2) NOT NULL DEFAULT '0.00',
bank_name varchar(50) NOT NULL DEFAULT '',
bank_user varchar(50) NOT NULL DEFAULT '',
faren varchar(20) NOT NULL DEFAULT '',
faren_tel varchar(20) NOT NULL DEFAULT '',
listorder int(8) unsigned NOT NULL DEFAULT 0,
status tinyint(1) NOT NULL DEFAULT 0,
create_time int(11) unsigned NOT NULL DEFAULT 0,
update_time int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY name(name),
KEY city_id(city_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
#商户账户表
CREATE TABLE o2o_bis_account(
id int(11) unsigned NOT NULL auto_increment,
username VARCHAR(50) NOT NULL DEFAULT '',
password char(32) NOT NULL DEFAULT '',
code VARCHAR(10) NOT NULL DEFAULT '',
bis_id int(11) unsigned NOT NULL DEFAULT 0,
last_login_ip VARCHAR(30) NOT NULL DEFAULT '',
last_login_time int(11) unsigned NOT NULL DEFAULT 0,
is_main tinyint(1) unsigned NOT NULL DEFAULT 0,
listorder int(8) unsigned NOT NULL DEFAULT 0,
status tinyint(1) NOT NULL DEFAULT 0,
create_time int(11) unsigned NOT NULL DEFAULT 0,
update_time int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY username(username),
KEY bis_id(bis_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
#商户门店表
CREATE TABLE o2o_bis_location(
id int(11) unsigned NOT NULL auto_increment,
name VARCHAR(50) NOT NULL DEFAULT '',
logo VARCHAR(255) NOT NULL DEFAULT '',
address VARCHAR(255) NOT NULL DEFAULT '',
tel VARCHAR(20) NOT NULL DEFAULT '',
contact VARCHAR(20) NOT NULL DEFAULT '',
xpoint VARCHAR(20) NOT NULL DEFAULT '',
ypoint VARCHAR(20) NOT NULL DEFAULT '',
bis_id int(11) unsigned NOT NULL DEFAULT 0,
open_time int(11) unsigned NOT NULL DEFAULT 0,
content text NOT NULL,
is_main tinyint(1) unsigned NOT NULL DEFAULT 0,
api_address VARCHAR(255) NOT NULL DEFAULT '',
city_id int(11) unsigned NOT NULL DEFAULT 0,
city_path varchar(50) NOT NULL DEFAULT '',
category_id int(11) unsigned NOT NULL DEFAULT 0,
category_path VARCHAR(50) NOT NULL DEFAULT '',
bank_info varchar(50) NOT NULL DEFAULT '',
listorder int(8) unsigned NOT NULL DEFAULT 0,
status tinyint(1) NOT NULL DEFAULT 0,
create_time int(11) unsigned NOT NULL DEFAULT 0,
update_time int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY name(name),
KEY city_id(city_id),
KEY bis_id(bis_id),
KEY category_id(category_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
#团购商品表
CREATE TABLE o2o_deal(
id int(11)