当前位置:网站首页>TP6的安装与测试
TP6的安装与测试
2022-08-09 05:05:00 【IT东东歌】
文档写的很详细 安装 · ThinkPHP6.0完全开发手册 · 看云
1、要求
- PHP >= 7.2.5
2、安装composer
如果遇到问题
在cmd命令下运行即可
set http_proxy=0
再次运行安装命令就成功安装了
安装详细过程文档有。
3、测试
<?php
namespace app\controller;
use app\BaseController;
use think\facade\Request;
class Index extends BaseController
{
public function index()
{
return 'index';
}
public function test($name = 'ThinkPHP6')
{
$arr = Request::param();//获取全部变量
$id = Request::param('id');
var_dump($arr);
var_dump($id);
return 'hello,' . $name;
}
}
post:
get:
http://tp6.com/index/test/name/123/id/456
接收参数成功。
4、链接数据库
当然首先配置数据库
1).env里配置
APP_DEBUG = true
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = map_edit
USERNAME = root
PASSWORD = root
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true[LANG]
default_lang = zh-cn
2)database.php里配置
如果两者都配置以 .env里为主
3)测试方法
控制器:
<?php
namespace app\controller;
use app\BaseController;
use think\facade\Request;
use app\model\User;
class Index extends BaseController
{
public function index()
{
return 'index';
}
public function test($name = 'ThinkPHP6')
{
$arr = Request::param();//获取全部变量
$id = Request::param('id');
var_dump($arr);
var_dump($id);
return 'hello,' . $name;
}
public function dbtest(){
$user = new User();
$res = $user->getUser();
var_dump($res);
}
}
数据模型
<?php
namespace app\model;
use think\Model;
class User extends Model
{
public function getUser() {
$res = User::where('user_name', 'yck')->find();
return $res;
}
}
数据库链接完毕!!
边栏推荐
- Pycharm Debug调试使用+代码调试理解
- [Harmony OS] [ArkUI] ets development graphics and animation drawing
- 如何选型APS系统,还需明确这七大关键因素
- JS-全局dom对象的使用---使用htm样式和js函数动作的完全分离
- C进阶 - 程序的编译(预处理操作) + 链接
- uboot中board_init bi_arch_number在哪
- dsafasfdasfasf
- 2022年8月深圳产品经理认证招生简章(NPDP)
- 【暑期每日一题】洛谷 P5724 【深基4.习5】求极差 / 最大跨度值
- ELTEK电源维修SMPS5000SIL整流器模块故障分析及特点
猜你喜欢
如何剪裁svg并压缩
【Harmony OS】【ARK UI】Date Basic Operation
【计算机网络-哈工大】---学习笔记(下)---(一)网络安全、密码学基础、对称、公钥、身份认证、数字签名、KDC\CA
【Harmony OS】【ArkUI】ets开发 图形与动画绘制
UI框架布局
JS-DOM-全局、局部、隐式变量,数组()\函数、 prompt输入对话框、confirm(确定用户的决定-弹出对话框)
2022下半年深圳信息系统项目管理师认证招生简章
还不了解什么是商业智能(BI)?看完这篇文章就懂了
【Harmony OS】【ARK UI】Lightweight Data Storage
C进阶 - 程序的编译(预处理操作) + 链接
随机推荐
How to choose an APS system, it is necessary to clarify these seven key factors
FastDFS快速使用及介绍
【LeetCode】761.特殊的二进制序列
leetcode:402. 移掉 K 位数字
【Harmony OS】【ARK UI】Lightweight Data Storage
【Harmony OS】【ArkUI】ets开发 创建视图与构建布局
Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
Hhhhgffsb
STM32定时器输入捕获频率(cube)
还不了解什么是商业智能(BI)?看完这篇文章就懂了
STM32系列单片机使用心得
leetcode:316. 去除重复字母
[MLT] Analysis of MLT Multimedia Framework Production and Consumption Architecture (2)
如何剪裁svg并压缩
【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
【HMS Core】【FAQ】【AR Engine】AR Engine FAQ
[Developers must see] [push kit] Collection of typical problems of push service service 2
Timing Constraint Basics
php uses phpoffice/phpspreadsheet to import and export excel tables
亚马逊面对风控,自养号测评时应该怎么做?